@rango-dev/provider-bitget 0.0.0-experimental-a84f27a7-20260921 → 0.0.0-experimental-214d73c7-20260922
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/hooks/utxo.d.ts +3 -1
- package/dist/hooks/utxo.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +3 -3
- package/dist/namespaces/evm.d.ts.map +1 -1
- package/dist/namespaces/tron.d.ts.map +1 -1
- package/dist/namespaces/utxo.d.ts.map +1 -1
- package/dist/signers/utxo.d.ts.map +1 -1
- package/package.json +11 -11
- package/readme.md +2 -0
- package/src/hooks/utxo.ts +45 -2
- package/src/namespaces/evm.ts +2 -1
- package/src/namespaces/tron.ts +6 -15
- package/src/namespaces/utxo.ts +5 -1
- package/src/signers/utxo.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [0.61.2](https://github.com/rango-exchange/rango-client/compare/provider-bitget@0.61.1...provider-bitget@0.61.2) (2026-09-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add jsonrpc field to btc broadcast requests ([2b96692](https://github.com/rango-exchange/rango-client/commit/2b96692a9e8941ec46285a2060593158ac9693e2))
|
|
1
7
|
## [0.61.1](https://github.com/rango-exchange/rango-client/compare/provider-bitget@0.61.0...provider-bitget@0.61.1) (2026-09-16)
|
|
2
8
|
|
|
3
9
|
|
package/dist/hooks/utxo.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ProviderAPI, UtxoActions } from '@hub3js/bip122';
|
|
2
|
-
import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';
|
|
2
|
+
import type { Context, Subscriber, SubscriberCleanUp } from '@hub3js/core';
|
|
3
3
|
declare function disconnectSubscriber(instance: () => ProviderAPI): [Subscriber<UtxoActions>, SubscriberCleanUp<UtxoActions>];
|
|
4
|
+
declare function classifyBitgetConnectionError(namespace: string): (context: Context, error: unknown) => unknown;
|
|
4
5
|
export declare const utxoHooks: {
|
|
5
6
|
disconnectSubscriber: typeof disconnectSubscriber;
|
|
7
|
+
classifyBitgetConnectionError: typeof classifyBitgetConnectionError;
|
|
6
8
|
};
|
|
7
9
|
export {};
|
|
8
10
|
//# sourceMappingURL=utxo.d.ts.map
|
package/dist/hooks/utxo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/hooks/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/hooks/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAEV,OAAO,EACP,UAAU,EACV,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAUtB,iBAAS,oBAAoB,CAC3B,QAAQ,EAAE,MAAM,WAAW,GAC1B,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAiC3D;AAED,iBAAS,6BAA6B,CAAC,SAAS,EAAE,MAAM,aACrC,OAAO,SAAS,OAAO,KAAG,OAAO,CAuBnD;AAED,eAAO,MAAM,SAAS;;;CAGrB,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Q=Object.defineProperty;var n=(o,t)=>Q(o,"name",{value:t,configurable:!0});import{defineVersions as Yt}from"@hub3js/core/utils";import{ProviderBuilder as Qt}from"@hub3js/core";import{CAIP_BITCOIN_CHAIN_ID as it,isChainSupported as ct}from"@hub3js/bip122";import{isEvmNamespace as st}from"@hub3js/evm";import{isTronNamespace as at}from"@rango-dev/wallets-core/namespaces/tron";import{EVM_NAMESPACE as ot,TRON_NAMESPACE as et,UTXO_NAMESPACE as nt}from"@hub3js/namespaces";import{DefaultSignerFactory as rt,TransactionType as E}from"rango-types";import{isBitcoinBlockchain as Y}from"@rango-dev/internal-blockchains";import*as v from"bitcoinjs-lib";import{SignerError as Z}from"rango-types";var tt="https://go.getblock.io/f37bad28a991436483c0a3679a3acbee",g=class{static{n(this,"BitgetUTXOSigner")}provider;constructor(t){this.provider=t}async signMessage(){throw Z.UnimplementedError("signMessage")}async signAndSendTx(t){let{asset:e,psbt:i}=t;if(!i)throw new Error("No PSBT found to sign. Ensure a valid PSBT is provided.");if(!Y(e.blockchain))throw new Error(`Signing ${e.blockchain} transaction is not implemented by the signer.`);let c=Buffer.from(i.unsignedPsbtBase64,"base64").toString("hex"),m=i.inputsToSign.flatMap(({address:u,signingIndexes:z})=>z.map(K=>({index:K,address:u}))),l;try{l=await this.provider.signPsbt(c,{autoFinalized:!0,toSignInputs:m})}catch(u){throw new Error(u?.message||"Error during signing transaction")}let J=v.Psbt.fromHex(l).extractTransaction().toHex(),A=await fetch(tt,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"sendrawtransaction",params:[J]})});if(!A.ok){let u=await A.text();throw new Error(`Error broadcasting transaction: ${u}`)}let f=await A.json();if(!f.result)throw new Error(`Error broadcasting transaction. Error Code ${f.error.code}: ${f.error.message}`);return{hash:f.result}}};async function w(o){let t=o.get(ot),e=o.get(et),i=o.get(nt),c=new rt,{DefaultEvmSigner:m}=await import("@rango-dev/signer-evm"),{DefaultTronSigner:l}=await import("@rango-dev/signer-tron");return t&&c.registerSigner(E.EVM,new m(t)),e&&c.registerSigner(E.TRON,new l(e)),i&&c.registerSigner(E.TRANSFER,new g(i)),c}n(w,"getSigners");import{EVM_NAMESPACE as T,TRON_NAMESPACE as y,UTXO_NAMESPACE as x}from"@hub3js/namespaces";function a(){let o=new Map,{bitkeep:t}=window;return!t||(t.ethereum&&o.set(T,t.ethereum),t.tronLink&&o.set(y,t.tronLink),t.unisat&&o.set(x,t.unisat),o.size===0)?null:o}n(a,"bitget");function S(){let o=a();if(!o)throw new Error("Bitget is not injected. Please check your wallet.");return o}n(S,"getInstanceOrThrow");function s(){let t=a()?.get(T);if(!t)throw new Error("Bitget not injected or EVM not enabled. Please check your wallet.");return t}n(s,"evmBitget");function p(){let t=a()?.get(y);if(!t)throw new Error("Bitget not injected or Tron not enabled. Please check your wallet.");return t}n(p,"tronBitget");function d(){let t=a()?.get(x);if(!t)throw new Error("Bitget not injected or BTC not enabled. Please check your wallet.");return t}n(d,"utxoBitget");var r="bitget",I=200,B={name:"Bitget",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/bitget/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak",brave:"https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak",homepage:"https://web3.bitget.com/en/wallet-download?type=1"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",isChainSupported:st},{label:"Tron",value:"Tron",id:"TRON",isChainSupported:at},{label:"BTC",value:"UTXO",id:"BTC",isChainSupported:ct([it])}]}},{name:"signers",value:{getSigners:async()=>w(S())}}]};import{NamespaceBuilder as mt}from"@hub3js/core";import{actions as b,builders as h,hooks as ut}from"@hub3js/evm";import{EVM_NAMESPACE as pt}from"@hub3js/namespaces";import*as _ from"@hub3js/std/builders";import{throwConnectionError as dt}from"@hub3js/std/operators";var[lt,N]=ut.changeAccountSubscriber(s),ft=h.connect().action(b.connect(s)).before(lt).or(N).or(dt({walletType:r,namespace:pt})).build(),gt=_.disconnect().after(N).build(),bt=h.canSwitchNetwork().action(b.canSwitchNetwork()).build(),ht=h.canEagerConnect().action(b.canEagerConnect(s)).build(),At=h.getChainId().action(b.getChainId(s)).build(),j=new mt("EVM",r).action(ft).action(gt).action(At).action(ht).action(bt).build();import{NamespaceBuilder as vt}from"@hub3js/core";import{TRON_NAMESPACE as Tt}from"@hub3js/namespaces";import*as M from"@hub3js/std/builders";import{throwConnectionError as yt}from"@hub3js/std/operators";import{utils as xt}from"@rango-dev/wallets-core/namespaces/tron";import{builders as O}from"@rango-dev/wallets-core/namespaces/tron";var Et=n(async()=>{let o=s();if(!p())throw new Error("Trying to eagerly connect to your wallet, but seems its tron instance is not available.");if(!o)throw new Error("Trying to eagerly connect to your EVM wallet, but seems its instance is not available.");try{return!!(await o.request({method:"eth_accounts"})).length}catch{return!1}},"canEagerConnectAction"),k={canEagerConnectAction:Et};import{ChangeAccountSubscriberBuilder as wt}from"@hub3js/std/hooks";import{utils as Ct}from"@rango-dev/wallets-core/namespaces/tron";var Pt=n(o=>new wt().getInstance(o).onSwitchAccount((t,e)=>{if(!t.payload.data.isBitkeep||t.payload.data.message?.action!=="accountsChanged"){t.preventDefault();return}t.payload.data.message.data.address||(t.preventDefault(),e.action("disconnect"))}).format(async(t,e)=>Ct.formatAccountsToCAIP([e.data.message.data.address])).addEventListener((t,e)=>{window.addEventListener("message",e)}).removeEventListener((t,e)=>{window.removeEventListener("message",e)}),"changeAccountSubscriber"),L={changeAccountSubscriber:Pt};var[St,U]=L.changeAccountSubscriber(p).build(),It=O.connect().action(async()=>{let o=p(),t=await o.request({method:"tron_requestAccounts"});if(t?.code&&t.message&&t.code!==I)throw new Error(t.message);return xt.formatAccountsToCAIP([o.tronWeb.defaultAddress.base58])}).before(St).or(U).or(yt({walletType:r,namespace:Tt})).build(),Bt=M.disconnect().after(U).build(),_t=O.canEagerConnect().action(k.canEagerConnectAction).build(),D=new vt("Tron",r).action(It).action(Bt).action(_t).build();import{builders as V}from"@hub3js/bip122";import{NamespaceBuilder as qt}from"@hub3js/core";import{UTXO_NAMESPACE as W}from"@hub3js/namespaces";import*as F from"@hub3js/std/builders";import{throwConnectionError as Xt}from"@hub3js/std/operators";import{CAIP_BITCOIN_CHAIN_ID as Nt,utils as jt}from"@hub3js/bip122";function kt(o){return async()=>{let t=o();if(!t)throw new Error("Do your wallet injected correctly and is utxo compatible?");let e=await t.requestAccounts();return jt.formatAccountsToCAIP(e,Nt)}}n(kt,"connect");function Lt(o){return async()=>!!(await o().getAccounts()).length}n(Lt,"canEagerConnect");var C={connect:kt,canEagerConnect:Lt};import{builders as Mt,CAIP_BITCOIN_CHAIN_ID as R,utils as Ot}from"@hub3js/bip122";var Ut=n(o=>Mt.changeAccountSubscriber(o,{network:R}).onSwitchAccount((t,e)=>{t.payload||(t.preventDefault(),e.action("disconnect"))}).format(async(t,e)=>Ot.formatAccountsToCAIP(e?[e]:[],R)).addEventListener((t,e)=>t.addListener("accountChanged",e)).removeEventListener((t,e)=>t.removeListener("accountChanged",e)),"changeAccountSubscriber"),H={changeAccountSubscriber:Ut};import{ConnectionErrorType as Dt,WalletConnectionError as Rt}from"@hub3js/std/utils";var Ht=-32603,Wt="User rejected the request";function Vt(o){let t;return[(e,i)=>{let c=o();if(!c)throw new Error("Trying to subscribe to your BTC wallet, but seems its instance is not available.");if(t=n(()=>{e.action("disconnect")},"eventCallback"),c.on("disconnect",t),i instanceof Error)throw i},(e,i)=>{let c=o();return t&&c&&c.removeListener("disconnect",t),i}]}n(Vt,"disconnectSubscriber");function Ft(o){return(t,e)=>{if(typeof e!="object"||e===null||!("code"in e)||e.code!==Ht||!("message"in e)||e.message!==Wt)return e;let[i]=t.state(),{accounts:c,...m}=i();return new Rt({walletType:r,namespace:o,type:Dt.Rejected,state:m,cause:e})}}n(Ft,"classifyBitgetConnectionError");var P={disconnectSubscriber:Vt,classifyBitgetConnectionError:Ft};var[Gt,q]=H.changeAccountSubscriber(d).build(),[$t,X]=P.disconnectSubscriber(d),Jt=V.connect().action(C.connect(d)).before(Gt).before($t).or(q).or(X).or(P.classifyBitgetConnectionError(W)).or(Xt({walletType:r,namespace:W})).build(),zt=F.disconnect().after(q).after(X).build(),Kt=V.canEagerConnect().action(C.canEagerConnect(d)).build(),G=new qt("UTXO",r).action(Jt).action(zt).action(Kt).build();var $=n(()=>new Qt(r).init(function(o){let[,t]=o.state();a()&&(t("installed",!0),console.debug("[bitget] instance detected.",o))}).config("metadata",B).add("tron",D).add("evm",j).add("utxo",G).build(),"buildProvider");var we=n(()=>Yt().version("1.0.0",$()).build(),"versions");export{r as WALLET_ID,we as versions};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/signers/utxo.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/namespaces/tron.ts", "../src/actions/tron.ts", "../src/builders/tron.ts", "../src/namespaces/utxo.ts", "../src/actions/utxo.ts", "../src/builders/utxo.ts", "../src/hooks/utxo.ts"],
|
|
4
|
-
"sourcesContent": ["import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\nexport { WALLET_ID } from './constants.js';\n", "import { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { tron } from './namespaces/tron.js';\nimport { utxo } from './namespaces/utxo.js';\nimport { bitget } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n if (bitget()) {\n setState('installed', true);\n console.debug('[bitget] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('tron', tron)\n .add('evm', evm)\n .add('utxo', utxo)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n isChainSupported as isBip122ChainSupported,\n} from '@hub3js/bip122';\nimport { isEvmNamespace } from '@hub3js/evm';\nimport { isTronNamespace } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'bitget';\nexport const TronOKRequestCode = 200;\n\nexport const metadata: ProviderMetadata = {\n name: 'Bitget',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/bitget/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak',\n brave:\n 'https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak',\n homepage: 'https://web3.bitget.com/en/wallet-download?type=1',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: isEvmNamespace,\n },\n {\n label: 'Tron',\n value: 'Tron',\n id: 'TRON',\n isChainSupported: isTronNamespace,\n },\n {\n label: 'BTC',\n value: 'UTXO',\n id: 'BTC',\n isChainSupported: isBip122ChainSupported([CAIP_BITCOIN_CHAIN_ID]),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners(getInstanceOrThrow()) },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport {\n EVM_NAMESPACE,\n TRON_NAMESPACE,\n UTXO_NAMESPACE,\n} from '@hub3js/namespaces';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { BitgetUTXOSigner } from './signers/utxo.js';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = provider.get(EVM_NAMESPACE);\n const tronProvider = provider.get(TRON_NAMESPACE);\n const utxoProvider = provider.get(UTXO_NAMESPACE);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');\n const { DefaultTronSigner } = await import('@rango-dev/signer-tron');\n if (!!ethProvider) {\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n }\n if (!!tronProvider) {\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));\n }\n if (!!utxoProvider) {\n signers.registerSigner(TxType.TRANSFER, new BitgetUTXOSigner(utxoProvider));\n }\n\n return signers;\n}\n", "import type { ProviderAPI } from '@hub3js/bip122';\nimport type { GenericSigner, Transfer } from 'rango-types';\n\nimport { isBitcoinBlockchain } from '@rango-dev/internal-blockchains';\nimport * as bitcoin from 'bitcoinjs-lib';\nimport { SignerError } from 'rango-types';\n\nconst BTC_RPC_URL = 'https://go.getblock.io/f37bad28a991436483c0a3679a3acbee';\n\nexport class BitgetUTXOSigner implements GenericSigner<Transfer> {\n private provider: ProviderAPI;\n constructor(provider: ProviderAPI) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: Transfer): Promise<{ hash: string }> {\n const { asset, psbt } = tx;\n if (!psbt) {\n throw new Error(\n 'No PSBT found to sign. Ensure a valid PSBT is provided.'\n );\n }\n\n if (!isBitcoinBlockchain(asset.blockchain)) {\n throw new Error(\n `Signing ${asset.blockchain} transaction is not implemented by the signer.`\n );\n }\n // 1. Decode Base64 to hex\n const psbtHex = Buffer.from(psbt.unsignedPsbtBase64, 'base64').toString(\n 'hex'\n );\n\n // 2. Build UniSat inputs\n const toSignInputs = psbt.inputsToSign.flatMap(\n ({ address, signingIndexes }) =>\n signingIndexes.map((index) => ({ index, address }))\n );\n\n // 3. Sign (& auto-finalize)\n let signedPsbtHex: string;\n try {\n signedPsbtHex = await this.provider.signPsbt(psbtHex, {\n autoFinalized: true,\n toSignInputs,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n throw new Error(error?.message || 'Error during signing transaction');\n }\n\n // 4. Parse the PSBT hex and extract the raw transaction\n const psbtObject = bitcoin.Psbt.fromHex(signedPsbtHex);\n const finalPsbtBaseHex = psbtObject.extractTransaction().toHex();\n\n /*\n * 5. Broadcast the raw transaction to the rpc node.\n * Broadcasting through Bitget's `pushPsbt` fails, so we submit the raw\n * transaction ourselves, the same way the UniSat signer does.\n */\n const response = await fetch(BTC_RPC_URL, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n method: 'sendrawtransaction',\n params: [finalPsbtBaseHex],\n }),\n });\n\n if (!response.ok) {\n // Handle network and fetch errors\n const errorText = await response.text();\n throw new Error(`Error broadcasting transaction: ${errorText}`);\n }\n\n const data = await response.json();\n\n if (!data.result) {\n // Handle Bitcoin specific errors\n throw new Error(\n `Error broadcasting transaction. Error Code ${data.error.code}: ${data.error.message}`\n );\n }\n\n return { hash: data.result };\n }\n}\n", "import type { Provider } from './types.js';\nimport type { ProviderAPI as UtxoProviderApi } from '@hub3js/bip122';\nimport type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';\nimport type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport {\n EVM_NAMESPACE,\n TRON_NAMESPACE,\n UTXO_NAMESPACE,\n} from '@hub3js/namespaces';\n\nexport function bitget(): Provider | null {\n const instances: Provider = new Map();\n const { bitkeep } = window;\n\n if (!bitkeep) {\n return null;\n }\n\n if (bitkeep.ethereum) {\n instances.set(EVM_NAMESPACE, bitkeep.ethereum);\n }\n\n if (bitkeep.tronLink) {\n instances.set(TRON_NAMESPACE, bitkeep.tronLink);\n }\n if (bitkeep.unisat) {\n instances.set(UTXO_NAMESPACE, bitkeep.unisat);\n }\n\n if (instances.size === 0) {\n return null;\n }\n\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = bitget();\n\n if (!instances) {\n throw new Error('Bitget is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmBitget(): EvmProviderApi {\n const instances = bitget();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'Bitget not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance;\n}\n\nexport function tronBitget(): TronProviderApi {\n const instance = bitget();\n const tronInstance = instance?.get(TRON_NAMESPACE);\n\n if (!tronInstance) {\n throw new Error(\n 'Bitget not injected or Tron not enabled. Please check your wallet.'\n );\n }\n\n return tronInstance;\n}\nexport function utxoBitget(): UtxoProviderApi {\n const instance = bitget();\n const utxoInstance = instance?.get(UTXO_NAMESPACE);\n\n if (!utxoInstance) {\n throw new Error(\n 'Bitget not injected or BTC not enabled. Please check your wallet.'\n );\n }\n\n return utxoInstance;\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, hooks } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { throwConnectionError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmBitget } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber(evmBitget);\nconst connect = builders\n .connect()\n .action(actions.connect(evmBitget))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(throwConnectionError({ walletType: WALLET_ID, namespace: 'EVM' }))\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmBitget))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmBitget))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(getChainId)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .build();\n\nexport { evm };\n", "import type { Context } from '@hub3js/core';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { throwConnectionError } from '@hub3js/std/operators';\nimport { WalletConnectionError } from '@hub3js/std/utils';\nimport {\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\nimport { builders } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { tronActions } from '../actions/tron.js';\nimport { tronBuilders } from '../builders/tron.js';\nimport { TronOKRequestCode, WALLET_ID } from '../constants.js';\nimport { tronBitget } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tronBuilders\n .changeAccountSubscriber(tronBitget)\n .build();\n\nconst connect = builders\n .connect()\n .action(async (context: Context) => {\n const instance = tronBitget();\n const accountsResult = await instance.request({\n method: 'tron_requestAccounts',\n });\n if (!accountsResult) {\n const [getState] = context.state();\n const { accounts, ...state } = getState();\n throw new WalletConnectionError({\n walletType: WALLET_ID,\n namespace: 'Tron',\n type: 'locked',\n state,\n });\n }\n\n if (\n !!accountsResult?.code &&\n !!accountsResult.message &&\n accountsResult.code !== TronOKRequestCode\n ) {\n throw new Error(accountsResult.message);\n }\n return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);\n })\n .before(changeAccountSubscriber)\n .or(throwConnectionError({ walletType: WALLET_ID, namespace: 'Tron' }))\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TronActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tronActions.canEagerConnectAction)\n .build();\n\nconst tron = new NamespaceBuilder<TronActions>('Tron', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { tron };\n", "import { evmBitget, tronBitget } from '../utils.js';\n\n/*\n * Bitget does not provide an eager connection mechanism for its Tron wallet.\n * The only workaround is to use the EVM-based eager connect approach.\n * However, this will only work if the EVM namespace has been connected at least once before.\n * If either wallet instance is unavailable, we throw an error.\n */\nconst canEagerConnectAction = async () => {\n const evmInstance = evmBitget();\n const tronInstance = tronBitget();\n // Making sure that the Tron instance is available first to prevent errors.\n if (!tronInstance) {\n throw new Error(\n 'Trying to eagerly connect to your wallet, but seems its tron instance is not available.'\n );\n }\n if (!evmInstance) {\n throw new Error(\n 'Trying to eagerly connect to your EVM wallet, but seems its instance is not available.'\n );\n }\n\n try {\n const accounts: string[] = await evmInstance.request({\n method: 'eth_accounts',\n });\n if (accounts.length) {\n return true;\n }\n return false;\n } catch {\n return false;\n }\n};\nexport const tronActions = { canEagerConnectAction };\n", "import type { TronChangeAccountEvent } from '../types.js';\n\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n type ProviderAPI,\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<\n MessageEvent<TronChangeAccountEvent>,\n ProviderAPI,\n TronActions\n >()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n if (\n !event.payload.data.isBitkeep ||\n event.payload.data.message?.action !== 'accountsChanged'\n ) {\n event.preventDefault();\n return;\n }\n if (!event.payload.data.message.data.address) {\n event.preventDefault();\n context.action('disconnect');\n }\n })\n .format(async (_, accounts) =>\n utils.formatAccountsToCAIP([accounts.data.message.data.address])\n )\n .addEventListener((_, callback) => {\n window.addEventListener('message', callback);\n })\n .removeEventListener((_, callback) => {\n window.removeEventListener('message', callback);\n });\n\nexport const tronBuilders = { changeAccountSubscriber };\n", "import type { UtxoActions } from '@hub3js/bip122';\n\nimport { builders } from '@hub3js/bip122';\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { throwConnectionError } from '@hub3js/std/operators';\n\nimport { utxoActions } from '../actions/utxo.js';\nimport { utxoBuilders } from '../builders/utxo.js';\nimport { WALLET_ID } from '../constants.js';\nimport { utxoHooks } from '../hooks/utxo.js';\nimport { utxoBitget } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = utxoBuilders\n .changeAccountSubscriber(utxoBitget)\n .build();\nconst [disconnectSubscriber, disconnectSubscriberCleanup] =\n utxoHooks.disconnectSubscriber(utxoBitget);\nconst connect = builders\n .connect()\n .action(utxoActions.connect(utxoBitget))\n .before(changeAccountSubscriber)\n .before(disconnectSubscriber)\n .or(changeAccountCleanup)\n .or(disconnectSubscriberCleanup)\n .or(throwConnectionError({ walletType: WALLET_ID, namespace: 'UTXO' }))\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<UtxoActions>()\n .after(changeAccountCleanup)\n .after(disconnectSubscriberCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(utxoActions.canEagerConnect(utxoBitget))\n .build();\n\nconst utxo = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { utxo };\n", "import type { ProviderAPI, UtxoActions } from '@hub3js/bip122';\nimport type {\n CanEagerConnect,\n Context,\n FunctionWithContext,\n} from '@hub3js/core';\n\nimport { CAIP_BITCOIN_CHAIN_ID, utils } from '@hub3js/bip122';\n\nexport function connect(\n instance: () => ProviderAPI\n): FunctionWithContext<UtxoActions['connect'], Context> {\n return async () => {\n const utxoInstance = instance();\n\n if (!utxoInstance) {\n throw new Error(\n 'Do your wallet injected correctly and is utxo compatible?'\n );\n }\n const accounts = await utxoInstance.requestAccounts();\n\n return utils.formatAccountsToCAIP(accounts, CAIP_BITCOIN_CHAIN_ID);\n };\n}\n\nexport function canEagerConnect(\n instance: () => ProviderAPI\n): CanEagerConnect<UtxoActions> {\n return async () => {\n const accounts = await instance().getAccounts();\n return !!accounts.length;\n };\n}\n\nexport const utxoActions = { connect, canEagerConnect };\n", "import type { ProviderAPI } from '@hub3js/bip122';\n\nimport { builders, CAIP_BITCOIN_CHAIN_ID, utils } from '@hub3js/bip122';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n builders\n .changeAccountSubscriber<string>(getInstance, {\n network: CAIP_BITCOIN_CHAIN_ID,\n })\n .onSwitchAccount((event, context) => {\n if (!event.payload) {\n event.preventDefault();\n context.action('disconnect');\n }\n })\n\n .format(async (_, address) => {\n return utils.formatAccountsToCAIP(\n address ? [address] : [],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .addEventListener((instance, callback) => {\n return instance.addListener('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n return instance.removeListener('accountChanged', callback);\n });\n\nexport const utxoBuilders = { changeAccountSubscriber };\n", "import type { ProviderAPI, UtxoActions } from '@hub3js/bip122';\nimport type { AnyFunction, Subscriber, SubscriberCleanUp } from '@hub3js/core';\n\nfunction disconnectSubscriber(\n instance: () => ProviderAPI\n): [Subscriber<UtxoActions>, SubscriberCleanUp<UtxoActions>] {\n let eventCallback: AnyFunction;\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const bitcoinInstance = instance();\n\n if (!bitcoinInstance) {\n throw new Error(\n 'Trying to subscribe to your BTC wallet, but seems its instance is not available.'\n );\n }\n\n eventCallback = () => {\n context.action('disconnect');\n };\n bitcoinInstance.on('disconnect', eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_context, err) => {\n const bitcoinInstance = instance();\n\n if (eventCallback && bitcoinInstance) {\n bitcoinInstance.removeListener('disconnect', eventCallback);\n }\n\n return err;\n },\n ];\n}\nexport const utxoHooks = { disconnectSubscriber };\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,kBAAAA,OAAsB,qBCA/B,OAAS,mBAAAC,OAAuB,eCEhC,OACE,yBAAAC,GACA,oBAAoBC,OACf,iBACP,OAAS,kBAAAC,OAAsB,cAC/B,OAAS,mBAAAC,OAAuB,0CCJhC,OACE,iBAAAC,
|
|
6
|
-
"names": ["defineVersions", "ProviderBuilder", "CAIP_BITCOIN_CHAIN_ID", "isBip122ChainSupported", "isEvmNamespace", "isTronNamespace", "EVM_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "DefaultSignerFactory", "TxType", "isBitcoinBlockchain", "bitcoin", "SignerError", "BTC_RPC_URL", "BitgetUTXOSigner", "__name", "provider", "SignerError", "tx", "asset", "psbt", "isBitcoinBlockchain", "psbtHex", "toSignInputs", "address", "signingIndexes", "index", "signedPsbtHex", "error", "finalPsbtBaseHex", "response", "errorText", "data", "getSigners", "provider", "ethProvider", "EVM_NAMESPACE", "tronProvider", "TRON_NAMESPACE", "utxoProvider", "UTXO_NAMESPACE", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "DefaultTronSigner", "TxType", "BitgetUTXOSigner", "__name", "EVM_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "bitget", "instances", "bitkeep", "EVM_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "__name", "getInstanceOrThrow", "evmBitget", "evmInstance", "tronBitget", "tronInstance", "utxoBitget", "utxoInstance", "WALLET_ID", "TronOKRequestCode", "metadata", "isEvmNamespace", "isTronNamespace", "isBip122ChainSupported", "CAIP_BITCOIN_CHAIN_ID", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "actions", "builders", "hooks", "commonBuilders", "throwConnectionError", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "evmBitget", "connect", "builders", "actions", "throwConnectionError", "WALLET_ID", "disconnect", "canSwitchNetwork", "canEagerConnect", "getChainId", "evm", "NamespaceBuilder", "NamespaceBuilder", "
|
|
4
|
+
"sourcesContent": ["import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\nexport { WALLET_ID } from './constants.js';\n", "import { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { tron } from './namespaces/tron.js';\nimport { utxo } from './namespaces/utxo.js';\nimport { bitget } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n if (bitget()) {\n setState('installed', true);\n console.debug('[bitget] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('tron', tron)\n .add('evm', evm)\n .add('utxo', utxo)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n isChainSupported as isBip122ChainSupported,\n} from '@hub3js/bip122';\nimport { isEvmNamespace } from '@hub3js/evm';\nimport { isTronNamespace } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'bitget';\nexport const TronOKRequestCode = 200;\n\nexport const metadata: ProviderMetadata = {\n name: 'Bitget',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/bitget/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak',\n brave:\n 'https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak',\n homepage: 'https://web3.bitget.com/en/wallet-download?type=1',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: isEvmNamespace,\n },\n {\n label: 'Tron',\n value: 'Tron',\n id: 'TRON',\n isChainSupported: isTronNamespace,\n },\n {\n label: 'BTC',\n value: 'UTXO',\n id: 'BTC',\n isChainSupported: isBip122ChainSupported([CAIP_BITCOIN_CHAIN_ID]),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners(getInstanceOrThrow()) },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport {\n EVM_NAMESPACE,\n TRON_NAMESPACE,\n UTXO_NAMESPACE,\n} from '@hub3js/namespaces';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { BitgetUTXOSigner } from './signers/utxo.js';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = provider.get(EVM_NAMESPACE);\n const tronProvider = provider.get(TRON_NAMESPACE);\n const utxoProvider = provider.get(UTXO_NAMESPACE);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');\n const { DefaultTronSigner } = await import('@rango-dev/signer-tron');\n if (!!ethProvider) {\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n }\n if (!!tronProvider) {\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));\n }\n if (!!utxoProvider) {\n signers.registerSigner(TxType.TRANSFER, new BitgetUTXOSigner(utxoProvider));\n }\n\n return signers;\n}\n", "import type { ProviderAPI } from '@hub3js/bip122';\nimport type { GenericSigner, Transfer } from 'rango-types';\n\nimport { isBitcoinBlockchain } from '@rango-dev/internal-blockchains';\nimport * as bitcoin from 'bitcoinjs-lib';\nimport { SignerError } from 'rango-types';\n\nconst BTC_RPC_URL = 'https://go.getblock.io/f37bad28a991436483c0a3679a3acbee';\n\nexport class BitgetUTXOSigner implements GenericSigner<Transfer> {\n private provider: ProviderAPI;\n constructor(provider: ProviderAPI) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: Transfer): Promise<{ hash: string }> {\n const { asset, psbt } = tx;\n if (!psbt) {\n throw new Error(\n 'No PSBT found to sign. Ensure a valid PSBT is provided.'\n );\n }\n\n if (!isBitcoinBlockchain(asset.blockchain)) {\n throw new Error(\n `Signing ${asset.blockchain} transaction is not implemented by the signer.`\n );\n }\n // 1. Decode Base64 to hex\n const psbtHex = Buffer.from(psbt.unsignedPsbtBase64, 'base64').toString(\n 'hex'\n );\n\n // 2. Build UniSat inputs\n const toSignInputs = psbt.inputsToSign.flatMap(\n ({ address, signingIndexes }) =>\n signingIndexes.map((index) => ({ index, address }))\n );\n\n // 3. Sign (& auto-finalize)\n let signedPsbtHex: string;\n try {\n signedPsbtHex = await this.provider.signPsbt(psbtHex, {\n autoFinalized: true,\n toSignInputs,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n throw new Error(error?.message || 'Error during signing transaction');\n }\n\n // 4. Parse the PSBT hex and extract the raw transaction\n const psbtObject = bitcoin.Psbt.fromHex(signedPsbtHex);\n const finalPsbtBaseHex = psbtObject.extractTransaction().toHex();\n\n /*\n * 5. Broadcast the raw transaction to the rpc node.\n * Broadcasting through Bitget's `pushPsbt` fails, so we submit the raw\n * transaction ourselves, the same way the UniSat signer does.\n */\n const response = await fetch(BTC_RPC_URL, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'sendrawtransaction',\n params: [finalPsbtBaseHex],\n }),\n });\n\n if (!response.ok) {\n // Handle network and fetch errors\n const errorText = await response.text();\n throw new Error(`Error broadcasting transaction: ${errorText}`);\n }\n\n const data = await response.json();\n\n if (!data.result) {\n // Handle Bitcoin specific errors\n throw new Error(\n `Error broadcasting transaction. Error Code ${data.error.code}: ${data.error.message}`\n );\n }\n\n return { hash: data.result };\n }\n}\n", "import type { Provider } from './types.js';\nimport type { ProviderAPI as UtxoProviderApi } from '@hub3js/bip122';\nimport type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';\nimport type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport {\n EVM_NAMESPACE,\n TRON_NAMESPACE,\n UTXO_NAMESPACE,\n} from '@hub3js/namespaces';\n\nexport function bitget(): Provider | null {\n const instances: Provider = new Map();\n const { bitkeep } = window;\n\n if (!bitkeep) {\n return null;\n }\n\n if (bitkeep.ethereum) {\n instances.set(EVM_NAMESPACE, bitkeep.ethereum);\n }\n\n if (bitkeep.tronLink) {\n instances.set(TRON_NAMESPACE, bitkeep.tronLink);\n }\n if (bitkeep.unisat) {\n instances.set(UTXO_NAMESPACE, bitkeep.unisat);\n }\n\n if (instances.size === 0) {\n return null;\n }\n\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = bitget();\n\n if (!instances) {\n throw new Error('Bitget is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmBitget(): EvmProviderApi {\n const instances = bitget();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'Bitget not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance;\n}\n\nexport function tronBitget(): TronProviderApi {\n const instance = bitget();\n const tronInstance = instance?.get(TRON_NAMESPACE);\n\n if (!tronInstance) {\n throw new Error(\n 'Bitget not injected or Tron not enabled. Please check your wallet.'\n );\n }\n\n return tronInstance;\n}\nexport function utxoBitget(): UtxoProviderApi {\n const instance = bitget();\n const utxoInstance = instance?.get(UTXO_NAMESPACE);\n\n if (!utxoInstance) {\n throw new Error(\n 'Bitget not injected or BTC not enabled. Please check your wallet.'\n );\n }\n\n return utxoInstance;\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, hooks } from '@hub3js/evm';\nimport { EVM_NAMESPACE } from '@hub3js/namespaces';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { throwConnectionError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmBitget } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber(evmBitget);\nconst connect = builders\n .connect()\n .action(actions.connect(evmBitget))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(throwConnectionError({ walletType: WALLET_ID, namespace: EVM_NAMESPACE }))\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmBitget))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmBitget))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(getChainId)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .build();\n\nexport { evm };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport { TRON_NAMESPACE } from '@hub3js/namespaces';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { throwConnectionError } from '@hub3js/std/operators';\nimport {\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\nimport { builders } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { tronActions } from '../actions/tron.js';\nimport { tronBuilders } from '../builders/tron.js';\nimport { TronOKRequestCode, WALLET_ID } from '../constants.js';\nimport { tronBitget } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tronBuilders\n .changeAccountSubscriber(tronBitget)\n .build();\n\nconst connect = builders\n .connect()\n .action(async () => {\n const instance = tronBitget();\n const accountsResult = await instance.request({\n method: 'tron_requestAccounts',\n });\n\n if (\n !!accountsResult?.code &&\n !!accountsResult.message &&\n accountsResult.code !== TronOKRequestCode\n ) {\n throw new Error(accountsResult.message);\n }\n return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);\n })\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(\n throwConnectionError({ walletType: WALLET_ID, namespace: TRON_NAMESPACE })\n )\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TronActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tronActions.canEagerConnectAction)\n .build();\n\nconst tron = new NamespaceBuilder<TronActions>('Tron', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { tron };\n", "import { evmBitget, tronBitget } from '../utils.js';\n\n/*\n * Bitget does not provide an eager connection mechanism for its Tron wallet.\n * The only workaround is to use the EVM-based eager connect approach.\n * However, this will only work if the EVM namespace has been connected at least once before.\n * If either wallet instance is unavailable, we throw an error.\n */\nconst canEagerConnectAction = async () => {\n const evmInstance = evmBitget();\n const tronInstance = tronBitget();\n // Making sure that the Tron instance is available first to prevent errors.\n if (!tronInstance) {\n throw new Error(\n 'Trying to eagerly connect to your wallet, but seems its tron instance is not available.'\n );\n }\n if (!evmInstance) {\n throw new Error(\n 'Trying to eagerly connect to your EVM wallet, but seems its instance is not available.'\n );\n }\n\n try {\n const accounts: string[] = await evmInstance.request({\n method: 'eth_accounts',\n });\n if (accounts.length) {\n return true;\n }\n return false;\n } catch {\n return false;\n }\n};\nexport const tronActions = { canEagerConnectAction };\n", "import type { TronChangeAccountEvent } from '../types.js';\n\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n type ProviderAPI,\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<\n MessageEvent<TronChangeAccountEvent>,\n ProviderAPI,\n TronActions\n >()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n if (\n !event.payload.data.isBitkeep ||\n event.payload.data.message?.action !== 'accountsChanged'\n ) {\n event.preventDefault();\n return;\n }\n if (!event.payload.data.message.data.address) {\n event.preventDefault();\n context.action('disconnect');\n }\n })\n .format(async (_, accounts) =>\n utils.formatAccountsToCAIP([accounts.data.message.data.address])\n )\n .addEventListener((_, callback) => {\n window.addEventListener('message', callback);\n })\n .removeEventListener((_, callback) => {\n window.removeEventListener('message', callback);\n });\n\nexport const tronBuilders = { changeAccountSubscriber };\n", "import type { UtxoActions } from '@hub3js/bip122';\n\nimport { builders } from '@hub3js/bip122';\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { UTXO_NAMESPACE } from '@hub3js/namespaces';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { throwConnectionError } from '@hub3js/std/operators';\n\nimport { utxoActions } from '../actions/utxo.js';\nimport { utxoBuilders } from '../builders/utxo.js';\nimport { WALLET_ID } from '../constants.js';\nimport { utxoHooks } from '../hooks/utxo.js';\nimport { utxoBitget } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = utxoBuilders\n .changeAccountSubscriber(utxoBitget)\n .build();\nconst [disconnectSubscriber, disconnectSubscriberCleanup] =\n utxoHooks.disconnectSubscriber(utxoBitget);\nconst connect = builders\n .connect()\n .action(utxoActions.connect(utxoBitget))\n .before(changeAccountSubscriber)\n .before(disconnectSubscriber)\n .or(changeAccountCleanup)\n .or(disconnectSubscriberCleanup)\n .or(utxoHooks.classifyBitgetConnectionError(UTXO_NAMESPACE))\n .or(\n throwConnectionError({ walletType: WALLET_ID, namespace: UTXO_NAMESPACE })\n )\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<UtxoActions>()\n .after(changeAccountCleanup)\n .after(disconnectSubscriberCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(utxoActions.canEagerConnect(utxoBitget))\n .build();\n\nconst utxo = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { utxo };\n", "import type { ProviderAPI, UtxoActions } from '@hub3js/bip122';\nimport type {\n CanEagerConnect,\n Context,\n FunctionWithContext,\n} from '@hub3js/core';\n\nimport { CAIP_BITCOIN_CHAIN_ID, utils } from '@hub3js/bip122';\n\nexport function connect(\n instance: () => ProviderAPI\n): FunctionWithContext<UtxoActions['connect'], Context> {\n return async () => {\n const utxoInstance = instance();\n\n if (!utxoInstance) {\n throw new Error(\n 'Do your wallet injected correctly and is utxo compatible?'\n );\n }\n const accounts = await utxoInstance.requestAccounts();\n\n return utils.formatAccountsToCAIP(accounts, CAIP_BITCOIN_CHAIN_ID);\n };\n}\n\nexport function canEagerConnect(\n instance: () => ProviderAPI\n): CanEagerConnect<UtxoActions> {\n return async () => {\n const accounts = await instance().getAccounts();\n return !!accounts.length;\n };\n}\n\nexport const utxoActions = { connect, canEagerConnect };\n", "import type { ProviderAPI } from '@hub3js/bip122';\n\nimport { builders, CAIP_BITCOIN_CHAIN_ID, utils } from '@hub3js/bip122';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n builders\n .changeAccountSubscriber<string>(getInstance, {\n network: CAIP_BITCOIN_CHAIN_ID,\n })\n .onSwitchAccount((event, context) => {\n if (!event.payload) {\n event.preventDefault();\n context.action('disconnect');\n }\n })\n\n .format(async (_, address) => {\n return utils.formatAccountsToCAIP(\n address ? [address] : [],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .addEventListener((instance, callback) => {\n return instance.addListener('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n return instance.removeListener('accountChanged', callback);\n });\n\nexport const utxoBuilders = { changeAccountSubscriber };\n", "import type { ProviderAPI, UtxoActions } from '@hub3js/bip122';\nimport type {\n AnyFunction,\n Context,\n Subscriber,\n SubscriberCleanUp,\n} from '@hub3js/core';\n\nimport { ConnectionErrorType, WalletConnectionError } from '@hub3js/std/utils';\n\nimport { WALLET_ID } from '../constants.js';\n\n// Bitget reports a UTXO rejection with the generic JSON-RPC internal error code, so its message is matched too.\nconst BITGET_UTXO_REJECTION_CODE = -32603;\nconst BITGET_UTXO_REJECTION_MESSAGE = 'User rejected the request';\n\nfunction disconnectSubscriber(\n instance: () => ProviderAPI\n): [Subscriber<UtxoActions>, SubscriberCleanUp<UtxoActions>] {\n let eventCallback: AnyFunction;\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const bitcoinInstance = instance();\n\n if (!bitcoinInstance) {\n throw new Error(\n 'Trying to subscribe to your BTC wallet, but seems its instance is not available.'\n );\n }\n\n eventCallback = () => {\n context.action('disconnect');\n };\n bitcoinInstance.on('disconnect', eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_context, err) => {\n const bitcoinInstance = instance();\n\n if (eventCallback && bitcoinInstance) {\n bitcoinInstance.removeListener('disconnect', eventCallback);\n }\n\n return err;\n },\n ];\n}\n\nfunction classifyBitgetConnectionError(namespace: string) {\n return (context: Context, error: unknown): unknown => {\n if (\n typeof error !== 'object' ||\n error === null ||\n !('code' in error) ||\n error.code !== BITGET_UTXO_REJECTION_CODE ||\n !('message' in error) ||\n error.message !== BITGET_UTXO_REJECTION_MESSAGE\n ) {\n return error;\n }\n\n const [getState] = context.state();\n const { accounts, ...state } = getState();\n\n return new WalletConnectionError({\n walletType: WALLET_ID,\n namespace,\n type: ConnectionErrorType.Rejected,\n state,\n cause: error,\n });\n };\n}\n\nexport const utxoHooks = {\n disconnectSubscriber,\n classifyBitgetConnectionError,\n};\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,kBAAAA,OAAsB,qBCA/B,OAAS,mBAAAC,OAAuB,eCEhC,OACE,yBAAAC,GACA,oBAAoBC,OACf,iBACP,OAAS,kBAAAC,OAAsB,cAC/B,OAAS,mBAAAC,OAAuB,0CCJhC,OACE,iBAAAC,GACA,kBAAAC,GACA,kBAAAC,OACK,qBACP,OAAS,wBAAAC,GAAsB,mBAAmBC,MAAc,cCLhE,OAAS,uBAAAC,MAA2B,kCACpC,UAAYC,MAAa,gBACzB,OAAS,eAAAC,MAAmB,cAE5B,IAAMC,GAAc,0DAEPC,EAAN,KAA0D,CATjE,MASiE,CAAAC,EAAA,yBACvD,SACR,YAAYC,EAAuB,CACjC,KAAK,SAAWA,CAClB,CAEA,MAAM,aAA+B,CACnC,MAAMC,EAAY,mBAAmB,aAAa,CACpD,CAEA,MAAM,cAAcC,EAAyC,CAC3D,GAA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AAe,EACtB,MAAM,ETvCT,IAAMG,EAAgBC,EAAA,IACpB,IAAIC,GAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAAS,CACvB,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EAE/BE,EAAO,IACTD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,8BAA+BD,CAAO,EAExD,CAAC,EACA,OAAO,WAAYG,CAAQ,EAC3B,IAAI,OAAQC,CAAI,EAChB,IAAI,MAAOC,CAAG,EACd,IAAI,OAAQC,CAAI,EAChB,MAAM,EAdW,iBDJtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EAAE,QAAQ,QAASC,EAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
+
"names": ["defineVersions", "ProviderBuilder", "CAIP_BITCOIN_CHAIN_ID", "isBip122ChainSupported", "isEvmNamespace", "isTronNamespace", "EVM_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "DefaultSignerFactory", "TxType", "isBitcoinBlockchain", "bitcoin", "SignerError", "BTC_RPC_URL", "BitgetUTXOSigner", "__name", "provider", "SignerError", "tx", "asset", "psbt", "isBitcoinBlockchain", "psbtHex", "toSignInputs", "address", "signingIndexes", "index", "signedPsbtHex", "error", "finalPsbtBaseHex", "response", "errorText", "data", "getSigners", "provider", "ethProvider", "EVM_NAMESPACE", "tronProvider", "TRON_NAMESPACE", "utxoProvider", "UTXO_NAMESPACE", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "DefaultTronSigner", "TxType", "BitgetUTXOSigner", "__name", "EVM_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "bitget", "instances", "bitkeep", "EVM_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "__name", "getInstanceOrThrow", "evmBitget", "evmInstance", "tronBitget", "tronInstance", "utxoBitget", "utxoInstance", "WALLET_ID", "TronOKRequestCode", "metadata", "isEvmNamespace", "isTronNamespace", "isBip122ChainSupported", "CAIP_BITCOIN_CHAIN_ID", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "actions", "builders", "hooks", "EVM_NAMESPACE", "commonBuilders", "throwConnectionError", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "evmBitget", "connect", "builders", "actions", "throwConnectionError", "WALLET_ID", "EVM_NAMESPACE", "disconnect", "canSwitchNetwork", "canEagerConnect", "getChainId", "evm", "NamespaceBuilder", "NamespaceBuilder", "TRON_NAMESPACE", "commonBuilders", "throwConnectionError", "utils", "builders", "canEagerConnectAction", "__name", "evmInstance", "evmBitget", "tronBitget", "tronActions", "ChangeAccountSubscriberBuilder", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "event", "context", "_", "accounts", "utils", "callback", "tronBuilders", "changeAccountSubscriber", "changeAccountCleanup", "tronBuilders", "tronBitget", "connect", "builders", "instance", "accountsResult", "TronOKRequestCode", "utils", "throwConnectionError", "WALLET_ID", "TRON_NAMESPACE", "disconnect", "canEagerConnect", "tronActions", "tron", "NamespaceBuilder", "builders", "NamespaceBuilder", "UTXO_NAMESPACE", "commonBuilders", "throwConnectionError", "CAIP_BITCOIN_CHAIN_ID", "utils", "connect", "instance", "utxoInstance", "accounts", "utils", "CAIP_BITCOIN_CHAIN_ID", "__name", "canEagerConnect", "utxoActions", "builders", "CAIP_BITCOIN_CHAIN_ID", "utils", "changeAccountSubscriber", "__name", "getInstance", "builders", "CAIP_BITCOIN_CHAIN_ID", "event", "context", "_", "address", "utils", "instance", "callback", "utxoBuilders", "ConnectionErrorType", "WalletConnectionError", "BITGET_UTXO_REJECTION_CODE", "BITGET_UTXO_REJECTION_MESSAGE", "disconnectSubscriber", "instance", "eventCallback", "context", "err", "bitcoinInstance", "__name", "_context", "classifyBitgetConnectionError", "namespace", "error", "getState", "accounts", "state", "WalletConnectionError", "WALLET_ID", "ConnectionErrorType", "utxoHooks", "changeAccountSubscriber", "changeAccountCleanup", "utxoBuilders", "utxoBitget", "disconnectSubscriber", "disconnectSubscriberCleanup", "utxoHooks", "connect", "builders", "utxoActions", "UTXO_NAMESPACE", "throwConnectionError", "WALLET_ID", "disconnect", "canEagerConnect", "utxo", "NamespaceBuilder", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "bitget", "metadata", "tron", "evm", "utxo", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/namespaces/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/namespaces/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAyC9C,QAAA,MAAM,GAAG,qDAMC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../../src/namespaces/tron.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../../src/namespaces/tron.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,WAAW,EAEjB,MAAM,yCAAyC,CAAC;AA8CjD,QAAA,MAAM,IAAI,sDAIA,CAAC;AAEX,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/namespaces/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/namespaces/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA2ClD,QAAA,MAAM,IAAI,sDAIA,CAAC;AAEX,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/signers/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ3D,qBAAa,gBAAiB,YAAW,aAAa,CAAC,QAAQ,CAAC;IAC9D,OAAO,CAAC,QAAQ,CAAc;gBAClB,QAAQ,EAAE,WAAW;IAI3B,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/signers/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ3D,qBAAa,gBAAiB,YAAW,aAAa,CAAC,QAAQ,CAAC;IAC9D,OAAO,CAAC,QAAQ,CAAc;gBAClB,QAAQ,EAAE,WAAW;IAI3B,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAyE7D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-bitget",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-214d73c7-20260922",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@hub3js/bip122": "0.0.0-experimental-
|
|
26
|
-
"@hub3js/core": "0.0.0-experimental-
|
|
27
|
-
"@hub3js/evm": "0.0.0-experimental-
|
|
28
|
-
"@hub3js/namespaces": "0.0.0-experimental-
|
|
29
|
-
"@hub3js/std": "0.0.0-experimental-
|
|
30
|
-
"@rango-dev/internal-blockchains": "^0.0.0-experimental-
|
|
31
|
-
"@rango-dev/signer-evm": "^0.
|
|
32
|
-
"@rango-dev/signer-tron": "^0.
|
|
33
|
-
"@rango-dev/wallets-core": "^0.0.0-experimental-
|
|
25
|
+
"@hub3js/bip122": "0.0.0-experimental-16dab4fe-20260922",
|
|
26
|
+
"@hub3js/core": "0.0.0-experimental-16dab4fe-20260922",
|
|
27
|
+
"@hub3js/evm": "0.0.0-experimental-16dab4fe-20260922",
|
|
28
|
+
"@hub3js/namespaces": "0.0.0-experimental-16dab4fe-20260922",
|
|
29
|
+
"@hub3js/std": "0.0.0-experimental-16dab4fe-20260922",
|
|
30
|
+
"@rango-dev/internal-blockchains": "^0.0.0-experimental-214d73c7-20260922",
|
|
31
|
+
"@rango-dev/signer-evm": "^0.0.0-experimental-214d73c7-20260922",
|
|
32
|
+
"@rango-dev/signer-tron": "^0.0.0-experimental-214d73c7-20260922",
|
|
33
|
+
"@rango-dev/wallets-core": "^0.0.0-experimental-214d73c7-20260922",
|
|
34
34
|
"bitcoinjs-lib": "^6.1.7",
|
|
35
|
-
"rango-types": "
|
|
35
|
+
"rango-types": "0.0.0-experimental-009f8a4d-20260921"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
package/readme.md
CHANGED
|
@@ -12,6 +12,8 @@ More about implementation status can be found [here](../readme.md).
|
|
|
12
12
|
Tron connection attempts can fail unpredictably, often returning an error on the **first or second try**.
|
|
13
13
|
Users may need to **retry the connection** to successfully establish a Tron session.
|
|
14
14
|
|
|
15
|
+
Bitget returns nothing meaningful when the user rejects the Tron connection request, so a rejection **can't be told apart** from other connection failures and is reported as `unknown`.
|
|
16
|
+
|
|
15
17
|
#### ⚠️ Switch Account
|
|
16
18
|
Switching accounts in the Bitget Wallet triggers a **full page refresh**.
|
|
17
19
|
Switch account would break if a single namespace account is connected.
|
package/src/hooks/utxo.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { ProviderAPI, UtxoActions } from '@hub3js/bip122';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AnyFunction,
|
|
4
|
+
Context,
|
|
5
|
+
Subscriber,
|
|
6
|
+
SubscriberCleanUp,
|
|
7
|
+
} from '@hub3js/core';
|
|
8
|
+
|
|
9
|
+
import { ConnectionErrorType, WalletConnectionError } from '@hub3js/std/utils';
|
|
10
|
+
|
|
11
|
+
import { WALLET_ID } from '../constants.js';
|
|
12
|
+
|
|
13
|
+
// Bitget reports a UTXO rejection with the generic JSON-RPC internal error code, so its message is matched too.
|
|
14
|
+
const BITGET_UTXO_REJECTION_CODE = -32603;
|
|
15
|
+
const BITGET_UTXO_REJECTION_MESSAGE = 'User rejected the request';
|
|
3
16
|
|
|
4
17
|
function disconnectSubscriber(
|
|
5
18
|
instance: () => ProviderAPI
|
|
@@ -37,4 +50,34 @@ function disconnectSubscriber(
|
|
|
37
50
|
},
|
|
38
51
|
];
|
|
39
52
|
}
|
|
40
|
-
|
|
53
|
+
|
|
54
|
+
function classifyBitgetConnectionError(namespace: string) {
|
|
55
|
+
return (context: Context, error: unknown): unknown => {
|
|
56
|
+
if (
|
|
57
|
+
typeof error !== 'object' ||
|
|
58
|
+
error === null ||
|
|
59
|
+
!('code' in error) ||
|
|
60
|
+
error.code !== BITGET_UTXO_REJECTION_CODE ||
|
|
61
|
+
!('message' in error) ||
|
|
62
|
+
error.message !== BITGET_UTXO_REJECTION_MESSAGE
|
|
63
|
+
) {
|
|
64
|
+
return error;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const [getState] = context.state();
|
|
68
|
+
const { accounts, ...state } = getState();
|
|
69
|
+
|
|
70
|
+
return new WalletConnectionError({
|
|
71
|
+
walletType: WALLET_ID,
|
|
72
|
+
namespace,
|
|
73
|
+
type: ConnectionErrorType.Rejected,
|
|
74
|
+
state,
|
|
75
|
+
cause: error,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const utxoHooks = {
|
|
81
|
+
disconnectSubscriber,
|
|
82
|
+
classifyBitgetConnectionError,
|
|
83
|
+
};
|
package/src/namespaces/evm.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { EvmActions } from '@hub3js/evm';
|
|
|
2
2
|
|
|
3
3
|
import { NamespaceBuilder } from '@hub3js/core';
|
|
4
4
|
import { actions, builders, hooks } from '@hub3js/evm';
|
|
5
|
+
import { EVM_NAMESPACE } from '@hub3js/namespaces';
|
|
5
6
|
import * as commonBuilders from '@hub3js/std/builders';
|
|
6
7
|
import { throwConnectionError } from '@hub3js/std/operators';
|
|
7
8
|
|
|
@@ -15,7 +16,7 @@ const connect = builders
|
|
|
15
16
|
.action(actions.connect(evmBitget))
|
|
16
17
|
.before(changeAccountSubscriber)
|
|
17
18
|
.or(changeAccountCleanup)
|
|
18
|
-
.or(throwConnectionError({ walletType: WALLET_ID, namespace:
|
|
19
|
+
.or(throwConnectionError({ walletType: WALLET_ID, namespace: EVM_NAMESPACE }))
|
|
19
20
|
.build();
|
|
20
21
|
|
|
21
22
|
const disconnect = commonBuilders
|
package/src/namespaces/tron.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { Context } from '@hub3js/core';
|
|
2
|
-
|
|
3
1
|
import { NamespaceBuilder } from '@hub3js/core';
|
|
2
|
+
import { TRON_NAMESPACE } from '@hub3js/namespaces';
|
|
4
3
|
import * as commonBuilders from '@hub3js/std/builders';
|
|
5
4
|
import { throwConnectionError } from '@hub3js/std/operators';
|
|
6
|
-
import { WalletConnectionError } from '@hub3js/std/utils';
|
|
7
5
|
import {
|
|
8
6
|
type TronActions,
|
|
9
7
|
utils,
|
|
@@ -21,21 +19,11 @@ const [changeAccountSubscriber, changeAccountCleanup] = tronBuilders
|
|
|
21
19
|
|
|
22
20
|
const connect = builders
|
|
23
21
|
.connect()
|
|
24
|
-
.action(async (
|
|
22
|
+
.action(async () => {
|
|
25
23
|
const instance = tronBitget();
|
|
26
24
|
const accountsResult = await instance.request({
|
|
27
25
|
method: 'tron_requestAccounts',
|
|
28
26
|
});
|
|
29
|
-
if (!accountsResult) {
|
|
30
|
-
const [getState] = context.state();
|
|
31
|
-
const { accounts, ...state } = getState();
|
|
32
|
-
throw new WalletConnectionError({
|
|
33
|
-
walletType: WALLET_ID,
|
|
34
|
-
namespace: 'Tron',
|
|
35
|
-
type: 'locked',
|
|
36
|
-
state,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
27
|
|
|
40
28
|
if (
|
|
41
29
|
!!accountsResult?.code &&
|
|
@@ -47,7 +35,10 @@ const connect = builders
|
|
|
47
35
|
return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);
|
|
48
36
|
})
|
|
49
37
|
.before(changeAccountSubscriber)
|
|
50
|
-
.or(
|
|
38
|
+
.or(changeAccountCleanup)
|
|
39
|
+
.or(
|
|
40
|
+
throwConnectionError({ walletType: WALLET_ID, namespace: TRON_NAMESPACE })
|
|
41
|
+
)
|
|
51
42
|
.build();
|
|
52
43
|
|
|
53
44
|
const disconnect = commonBuilders
|
package/src/namespaces/utxo.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { UtxoActions } from '@hub3js/bip122';
|
|
|
2
2
|
|
|
3
3
|
import { builders } from '@hub3js/bip122';
|
|
4
4
|
import { NamespaceBuilder } from '@hub3js/core';
|
|
5
|
+
import { UTXO_NAMESPACE } from '@hub3js/namespaces';
|
|
5
6
|
import * as commonBuilders from '@hub3js/std/builders';
|
|
6
7
|
import { throwConnectionError } from '@hub3js/std/operators';
|
|
7
8
|
|
|
@@ -23,7 +24,10 @@ const connect = builders
|
|
|
23
24
|
.before(disconnectSubscriber)
|
|
24
25
|
.or(changeAccountCleanup)
|
|
25
26
|
.or(disconnectSubscriberCleanup)
|
|
26
|
-
.or(
|
|
27
|
+
.or(utxoHooks.classifyBitgetConnectionError(UTXO_NAMESPACE))
|
|
28
|
+
.or(
|
|
29
|
+
throwConnectionError({ walletType: WALLET_ID, namespace: UTXO_NAMESPACE })
|
|
30
|
+
)
|
|
27
31
|
.build();
|
|
28
32
|
|
|
29
33
|
const disconnect = commonBuilders
|
package/src/signers/utxo.ts
CHANGED
|
@@ -66,6 +66,8 @@ export class BitgetUTXOSigner implements GenericSigner<Transfer> {
|
|
|
66
66
|
method: 'POST',
|
|
67
67
|
headers: { 'Content-Type': 'application/json' },
|
|
68
68
|
body: JSON.stringify({
|
|
69
|
+
jsonrpc: '2.0',
|
|
70
|
+
id: 1,
|
|
69
71
|
method: 'sendrawtransaction',
|
|
70
72
|
params: [finalPsbtBaseHex],
|
|
71
73
|
}),
|