From 5268dce7b815880e82e34353ba27b33e9fd08dc0 Mon Sep 17 00:00:00 2001 From: Nayan Das Date: Mon, 26 Jan 2026 16:24:00 +0530 Subject: [PATCH] feat(sdk-coin-tempo): integrate Tempo SDK and update references Ticket: WIN-8719 --- Dockerfile | 3 ++ modules/account-lib/package.json | 1 + modules/account-lib/src/index.ts | 5 ++++ modules/account-lib/tsconfig.json | 3 ++ modules/bitgo/package.json | 1 + modules/bitgo/src/v2/coinFactory.ts | 17 +++++++++++ modules/bitgo/src/v2/coins/index.ts | 2 ++ modules/bitgo/test/browser/browser.spec.ts | 1 + modules/bitgo/tsconfig.json | 3 ++ modules/sdk-coin-tempo/src/lib/keyPair.ts | 33 ++-------------------- modules/sdk-coin-tempo/src/tip20Token.ts | 24 ++++++---------- tsconfig.packages.json | 3 ++ 12 files changed, 50 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1730db9774..99acdf7169 100644 --- a/Dockerfile +++ b/Dockerfile @@ -109,6 +109,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-stt /var/modules/sdk-coin-stt/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-stx /var/modules/sdk-coin-stx/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-sui /var/modules/sdk-coin-sui/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-tao /var/modules/sdk-coin-tao/ +COPY --from=builder /tmp/bitgo/modules/sdk-coin-tempo /var/modules/sdk-coin-tempo/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-tia /var/modules/sdk-coin-tia/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-ton /var/modules/sdk-coin-ton/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-trx /var/modules/sdk-coin-trx/ @@ -207,6 +208,7 @@ cd /var/modules/sdk-coin-stt && yarn link && \ cd /var/modules/sdk-coin-stx && yarn link && \ cd /var/modules/sdk-coin-sui && yarn link && \ cd /var/modules/sdk-coin-tao && yarn link && \ +cd /var/modules/sdk-coin-tempo && yarn link && \ cd /var/modules/sdk-coin-tia && yarn link && \ cd /var/modules/sdk-coin-ton && yarn link && \ cd /var/modules/sdk-coin-trx && yarn link && \ @@ -308,6 +310,7 @@ RUN cd /var/bitgo-express && \ yarn link @bitgo/sdk-coin-stx && \ yarn link @bitgo/sdk-coin-sui && \ yarn link @bitgo/sdk-coin-tao && \ + yarn link @bitgo/sdk-coin-tempo && \ yarn link @bitgo/sdk-coin-tia && \ yarn link @bitgo/sdk-coin-ton && \ yarn link @bitgo/sdk-coin-trx && \ diff --git a/modules/account-lib/package.json b/modules/account-lib/package.json index 45aad3a73c..ac2223fbe1 100644 --- a/modules/account-lib/package.json +++ b/modules/account-lib/package.json @@ -76,6 +76,7 @@ "@bitgo/sdk-coin-stx": "^3.10.24", "@bitgo/sdk-coin-sui": "^5.19.24", "@bitgo/sdk-coin-tao": "^1.13.4", + "@bitgo/sdk-coin-tempo": "^1.3.2", "@bitgo/sdk-coin-tia": "^3.5.24", "@bitgo/sdk-coin-ton": "^3.13.3", "@bitgo/sdk-coin-trx": "^3.8.4", diff --git a/modules/account-lib/src/index.ts b/modules/account-lib/src/index.ts index 703c1aa01f..c70d173eaa 100644 --- a/modules/account-lib/src/index.ts +++ b/modules/account-lib/src/index.ts @@ -170,6 +170,9 @@ export { Apechain }; import * as Tao from '@bitgo/sdk-coin-tao'; export { Tao }; +import * as Tempo from '@bitgo/sdk-coin-tempo'; +export { Tempo }; + import * as Icp from '@bitgo/sdk-coin-icp'; export { Icp }; @@ -292,6 +295,8 @@ const coinBuilderMap = { tapt: Apt.TransactionBuilder, tao: Tao.TransactionBuilderFactory, ttao: Tao.TransactionBuilderFactory, + tempo: Tempo.Tip20TransactionBuilder, + ttempo: Tempo.Tip20TransactionBuilder, icp: Icp.TransactionBuilder, ticp: Icp.TransactionBuilder, baby: Baby.TransactionBuilder, diff --git a/modules/account-lib/tsconfig.json b/modules/account-lib/tsconfig.json index d683523bbe..4b6b79cabf 100644 --- a/modules/account-lib/tsconfig.json +++ b/modules/account-lib/tsconfig.json @@ -121,6 +121,9 @@ { "path": "../sdk-coin-tia" }, + { + "path": "../sdk-coin-tempo" + }, { "path": "../sdk-coin-trx" }, diff --git a/modules/bitgo/package.json b/modules/bitgo/package.json index efcbb99b80..9f9a3984ad 100644 --- a/modules/bitgo/package.json +++ b/modules/bitgo/package.json @@ -110,6 +110,7 @@ "@bitgo/sdk-coin-stx": "^3.10.24", "@bitgo/sdk-coin-sui": "^5.19.24", "@bitgo/sdk-coin-tao": "^1.13.4", + "@bitgo/sdk-coin-tempo": "^1.3.2", "@bitgo/sdk-coin-tia": "^3.5.24", "@bitgo/sdk-coin-ton": "^3.13.3", "@bitgo/sdk-coin-trx": "^3.8.4", diff --git a/modules/bitgo/src/v2/coinFactory.ts b/modules/bitgo/src/v2/coinFactory.ts index 89c7ea385a..12a0d84b02 100644 --- a/modules/bitgo/src/v2/coinFactory.ts +++ b/modules/bitgo/src/v2/coinFactory.ts @@ -37,6 +37,7 @@ import { CosmosTokenConfig, VetTokenConfig, TaoTokenConfig, + Tip20TokenConfig, PolyxTokenConfig, JettonTokenConfig, } from '@bitgo/statics'; @@ -133,6 +134,8 @@ import { Susd, Tao, TaoToken, + Tempo, + Tip20Token, Ton, Tada, Talgo, @@ -200,6 +203,7 @@ import { Twemix, Tworld, Ttao, + Ttempo, Ttia, Tton, Ttrx, @@ -304,6 +308,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin coinFactory.register('sui', Sui.createInstance); coinFactory.register('susd', Susd.createInstance); coinFactory.register('tao', Tao.createInstance); + coinFactory.register('tempo', Tempo.createInstance); coinFactory.register('tia', Tia.createInstance); coinFactory.register('ton', Ton.createInstance); coinFactory.register('talgo', Talgo.createInstance); @@ -373,6 +378,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin coinFactory.register('tsui', Tsui.createInstance); coinFactory.register('tsusd', Tsusd.createInstance); coinFactory.register('ttao', Ttao.createInstance); + coinFactory.register('ttempo', Ttempo.createInstance); coinFactory.register('ttia', Ttia.createInstance); coinFactory.register('tton', Tton.createInstance); coinFactory.register('ttrx', Ttrx.createInstance); @@ -522,6 +528,10 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin ({ name, coinConstructor }) => coinFactory.register(name, coinConstructor) ); + Tip20Token.createTokenConstructors([...tokens.bitcoin.tempo.tokens, ...tokens.testnet.tempo.tokens]).forEach( + ({ name, coinConstructor }) => coinFactory.register(name, coinConstructor) + ); + PolyxToken.createTokenConstructors([...tokens.bitcoin.polyx.tokens, ...tokens.testnet.polyx.tokens]).forEach( ({ name, coinConstructor }) => coinFactory.register(name, coinConstructor) ); @@ -751,6 +761,8 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine return Susd.createInstance; case 'tao': return Tao.createInstance; + case 'tempo': + return Tempo.createInstance; case 'tia': return Tia.createInstance; case 'ton': @@ -889,6 +901,8 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine return Tsusd.createInstance; case 'ttao': return Ttao.createInstance; + case 'ttempo': + return Ttempo.createInstance; case 'ttia': return Ttia.createInstance; case 'tton': @@ -1043,6 +1057,9 @@ export function getTokenConstructor(tokenConfig: TokenConfig): CoinConstructor | case 'tao': case 'ttao': return TaoToken.createTokenConstructor(tokenConfig as TaoTokenConfig); + case 'tempo': + case 'ttempo': + return Tip20Token.createTokenConstructor(tokenConfig as Tip20TokenConfig); case 'polyx': case 'tpolyx': return PolyxToken.createTokenConstructor(tokenConfig as PolyxTokenConfig); diff --git a/modules/bitgo/src/v2/coins/index.ts b/modules/bitgo/src/v2/coins/index.ts index 43c9beedf4..d7c16bb612 100644 --- a/modules/bitgo/src/v2/coins/index.ts +++ b/modules/bitgo/src/v2/coins/index.ts @@ -61,6 +61,7 @@ import { Sol, Tsol } from '@bitgo/sdk-coin-sol'; import { Stx, Tstx, Sip10Token } from '@bitgo/sdk-coin-stx'; import { Sui, Tsui, SuiToken } from '@bitgo/sdk-coin-sui'; import { Tao, Ttao, TaoToken } from '@bitgo/sdk-coin-tao'; +import { Tempo, Ttempo, Tip20Token } from '@bitgo/sdk-coin-tempo'; import { Tia, Ttia } from '@bitgo/sdk-coin-tia'; import { Ton, Tton, JettonToken } from '@bitgo/sdk-coin-ton'; import { Trx, Ttrx } from '@bitgo/sdk-coin-trx'; @@ -134,6 +135,7 @@ export { Tstt }; export { Stx, Tstx, Sip10Token }; export { Sui, Tsui, SuiToken }; export { Tao, Ttao, TaoToken }; +export { Tempo, Ttempo, Tip20Token }; export { Tia, Ttia }; export { Ton, Tton, JettonToken }; export { Bld, Tbld }; diff --git a/modules/bitgo/test/browser/browser.spec.ts b/modules/bitgo/test/browser/browser.spec.ts index b756a2a8e6..3326566984 100644 --- a/modules/bitgo/test/browser/browser.spec.ts +++ b/modules/bitgo/test/browser/browser.spec.ts @@ -61,6 +61,7 @@ describe('Coins', () => { MonToken: 1, XdcToken: 1, JettonToken: 1, + Tip20Token: 1, }; Object.keys(BitGoJS.Coin) .filter((coinName) => !excludedKeys[coinName]) diff --git a/modules/bitgo/tsconfig.json b/modules/bitgo/tsconfig.json index 29f7f5939d..5f24815255 100644 --- a/modules/bitgo/tsconfig.json +++ b/modules/bitgo/tsconfig.json @@ -236,6 +236,9 @@ { "path": "../sdk-coin-tao" }, + { + "path": "../sdk-coin-tempo" + }, { "path": "../sdk-coin-tia" }, diff --git a/modules/sdk-coin-tempo/src/lib/keyPair.ts b/modules/sdk-coin-tempo/src/lib/keyPair.ts index aa4cfb8f8f..e45e7672d8 100644 --- a/modules/sdk-coin-tempo/src/lib/keyPair.ts +++ b/modules/sdk-coin-tempo/src/lib/keyPair.ts @@ -2,36 +2,7 @@ * Tempo KeyPair - Reuses Ethereum KeyPair Implementation * * Since Tempo is EVM-compatible and uses the same cryptography (ECDSA/secp256k1) - * as Ethereum, we can directly reuse the Ethereum KeyPair implementation. + * as Ethereum, we directly reuse the Ethereum KeyPair implementation from abstract-eth. */ -import { bip32 } from '@bitgo/secp256k1'; -import { DefaultKeys, KeyPairOptions } from '@bitgo/sdk-core'; - -/** - * Tempo KeyPair class - * Uses same key derivation as Ethereum (BIP32 + secp256k1) - */ -export class KeyPair { - private keyPair: DefaultKeys; - - constructor(source?: KeyPairOptions) { - // TODO: Implement proper key generation when needed - const seed = Buffer.alloc(64); - const hdNode = bip32.fromSeed(seed); - - this.keyPair = { - prv: hdNode.toBase58(), - pub: hdNode.neutered().toBase58(), - }; - } - - getKeys(): DefaultKeys { - return this.keyPair; - } - - getAddress(): string { - // TODO: Implement Ethereum-style address derivation - return '0x0000000000000000000000000000000000000000'; - } -} +export { KeyPair } from '@bitgo/abstract-eth'; diff --git a/modules/sdk-coin-tempo/src/tip20Token.ts b/modules/sdk-coin-tempo/src/tip20Token.ts index 23efb2d29f..d34408dc85 100644 --- a/modules/sdk-coin-tempo/src/tip20Token.ts +++ b/modules/sdk-coin-tempo/src/tip20Token.ts @@ -2,23 +2,13 @@ * @prettier */ import { BitGoBase, CoinConstructor, MPCAlgorithm, NamedCoinConstructor } from '@bitgo/sdk-core'; -import { coins } from '@bitgo/statics'; +import { coins, Tip20TokenConfig } from '@bitgo/statics'; import { GetSendMethodArgsOptions, SendMethodArgs } from '@bitgo/abstract-eth'; import { Address } from './lib/types'; import { Tempo } from './tempo'; import { encodeTip20TransferWithMemo, amountToTip20Units, isValidAddress, isValidTip20Amount } from './lib/utils'; -/** - * TIP20 Token Configuration Interface - */ -export interface Tip20TokenConfig { - type: string; // Token identifier (e.g., 'tempo:usdc') - coin: string; // Base coin (e.g., 'tempo' or 'ttempo') - network: 'Mainnet' | 'Testnet'; - name: string; // Token full name - tokenContractAddress: string; // Smart contract address (0x...) - decimalPlaces: number; // Token decimal places -} +export { Tip20TokenConfig }; /** * TIP20 Token Implementation (Skeleton) @@ -31,8 +21,7 @@ export class Tip20Token extends Tempo { public readonly tokenConfig: Tip20TokenConfig; constructor(bitgo: BitGoBase, tokenConfig: Tip20TokenConfig) { - const coinName = tokenConfig.network === 'Mainnet' ? 'tempo' : 'ttempo'; - const staticsCoin = coins.get(coinName); + const staticsCoin = tokenConfig.network === 'Mainnet' ? coins.get('tempo') : coins.get('ttempo'); super(bitgo, staticsCoin); this.tokenConfig = tokenConfig; } @@ -79,7 +68,7 @@ export class Tip20Token extends Tempo { } /** Get the network */ - get network(): 'Mainnet' | 'Testnet' { + get network(): string { return this.tokenConfig.network; } @@ -98,6 +87,11 @@ export class Tip20Token extends Tempo { return this.tokenConfig.type; } + /** @inheritDoc */ + getBaseChain(): string { + return this.coin; + } + /** @inheritDoc */ getFullName(): string { return 'TIP20 Token'; diff --git a/tsconfig.packages.json b/tsconfig.packages.json index cbfd203ba3..968aa19595 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -223,6 +223,9 @@ { "path": "./modules/sdk-coin-tao" }, + { + "path": "./modules/sdk-coin-tempo" + }, { "path": "./modules/sdk-coin-tia" },