@rango-dev/provider-okx 0.63.1-next.2 → 0.63.1-next.4
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/dist/actions/ton.d.ts +1 -1
- package/dist/actions/ton.d.ts.map +1 -1
- package/dist/actions/tron.d.ts +5 -0
- package/dist/actions/tron.d.ts.map +1 -0
- package/dist/builders/ton.d.ts +1 -1
- package/dist/builders/ton.d.ts.map +1 -1
- package/dist/builders/tron.d.ts +7 -0
- package/dist/builders/tron.d.ts.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/hooks/sui.d.ts +8 -0
- package/dist/hooks/sui.d.ts.map +1 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/dist/namespaces/sui.d.ts +4 -0
- package/dist/namespaces/sui.d.ts.map +1 -0
- package/dist/namespaces/ton/ton.d.ts +1 -1
- package/dist/namespaces/ton/ton.d.ts.map +1 -1
- package/dist/namespaces/ton/utils.d.ts +1 -1
- package/dist/namespaces/ton/utils.d.ts.map +1 -1
- package/dist/namespaces/tron.d.ts +4 -0
- package/dist/namespaces/tron.d.ts.map +1 -0
- package/dist/provider.d.ts +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/signer.d.ts.map +1 -1
- package/dist/types.d.ts +11 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +5 -1
- package/readme.md +17 -3
- package/src/actions/ton.ts +1 -1
- package/src/actions/tron.ts +37 -0
- package/src/builders/ton.ts +1 -1
- package/src/builders/tron.ts +63 -0
- package/src/constants.ts +24 -0
- package/src/hooks/sui.ts +46 -0
- package/src/namespaces/sui.ts +53 -0
- package/src/namespaces/ton/ton.ts +1 -4
- package/src/namespaces/ton/utils.ts +2 -2
- package/src/namespaces/tron.ts +40 -0
- package/src/provider.ts +4 -0
- package/src/signer.ts +15 -0
- package/src/types.ts +16 -0
- package/src/utils.ts +49 -2
package/dist/actions/ton.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TonProviderApi } from '../namespaces/ton/types.js';
|
|
2
2
|
import type { Context, FunctionWithContext } from '@hub3js/core';
|
|
3
|
-
import { type TonActions } from '@
|
|
3
|
+
import { type TonActions } from '@hub3js/tvm';
|
|
4
4
|
export declare function connect(getInstance: () => TonProviderApi): FunctionWithContext<TonActions['connect'], Context>;
|
|
5
5
|
export declare function canEagerConnect(getInstance: () => TonProviderApi): FunctionWithContext<TonActions['canEagerConnect'], Context>;
|
|
6
6
|
export declare function disconnect(getInstance: () => TonProviderApi): () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/actions/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/actions/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAa9C,wBAAgB,OAAO,CACrB,WAAW,EAAE,MAAM,cAAc,GAChC,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAwCrD;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,cAAc,GAChC,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAa7D;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,cAAc,uBAgB3D;AAED,eAAO,MAAM,UAAU;;;;CAA2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../../src/actions/tron.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,WAAW;;;CAA+B,CAAC"}
|
package/dist/builders/ton.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TonProviderApi } from '../namespaces/ton/types.js';
|
|
2
2
|
import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';
|
|
3
|
-
import { type TonActions } from '@
|
|
3
|
+
import { type TonActions } from '@hub3js/tvm';
|
|
4
4
|
export declare const changeAccountSubscriber: (getInstance: () => TonProviderApi) => ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>;
|
|
5
5
|
export declare const disconnectSubscriber: (getInstance: () => TonProviderApi) => ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>;
|
|
6
6
|
export declare const tonBuilders: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/builders/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/builders/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,aAAa,CAAC;AAUrD,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,cAAc,wEAiBnE,CAAC;AAEP,eAAO,MAAM,oBAAoB,gBAAiB,MAAM,cAAc,wEAahE,CAAC;AAEP,eAAO,MAAM,WAAW;2CAlC6B,MAAM,cAAc;wCAmBvB,MAAM,cAAc;CAeM,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';
|
|
2
|
+
import { type ProviderAPI, type TronActions } from '@rango-dev/wallets-core/namespaces/tron';
|
|
3
|
+
export declare const changeAccountSubscriber: (getInstance: () => ProviderAPI) => ChangeAccountSubscriberBuilder<MessageEvent<unknown>, ProviderAPI, TronActions>;
|
|
4
|
+
export declare const tronBuilders: {
|
|
5
|
+
changeAccountSubscriber: (getInstance: () => ProviderAPI) => ChangeAccountSubscriberBuilder<MessageEvent<unknown>, ProviderAPI, TronActions>;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=tron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../../src/builders/tron.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEjB,MAAM,yCAAyC,CAAC;AAIjD,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,WAAW,oFAmDhE,CAAC;AAEP,eAAO,MAAM,YAAY;2CArD4B,MAAM,WAAW;CAqDf,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
|
3
3
|
export declare const WALLET_ID = "okx";
|
|
4
4
|
export declare const TON_CONNECT_PROTOCOL_VERSION = 2;
|
|
5
5
|
export declare const TON_CONNECT_USER_REJECTED_CODE = 300;
|
|
6
|
+
export declare const TRON_OK_REQUEST_CODE = 200;
|
|
7
|
+
export declare const TRON_USER_REJECTION_CODE = 4001;
|
|
8
|
+
export declare const WALLET_NAME_IN_WALLET_STANDARD = "OKX Wallet";
|
|
6
9
|
export declare const OKX_WALLET_SUPPORTED_CHAINS: LegacyNetworks[];
|
|
7
10
|
export declare const metadata: ProviderMetadata;
|
|
8
11
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAehE,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,8BAA8B,eAAe,CAAC;AAE3D,eAAO,MAAM,2BAA2B,kBAcvC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,gBA6EtB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';
|
|
2
|
+
import type { ProviderAPI, SuiActions } from '@hub3js/sui';
|
|
3
|
+
declare function disconnectSubscriber(getInstance: () => ProviderAPI): [Subscriber<SuiActions>, SubscriberCleanUp<SuiActions>];
|
|
4
|
+
export declare const suiHooks: {
|
|
5
|
+
disconnectSubscriber: typeof disconnectSubscriber;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/hooks/sui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAU3D,iBAAS,oBAAoB,CAC3B,WAAW,EAAE,MAAM,WAAW,GAC7B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,CA8BzD;AAED,eAAO,MAAM,QAAQ;;CAA2B,CAAC"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@rango-dev/wallets-core/namespaces/
|
|
1
|
+
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@hub3js/tvm").TonActions> & Record<"tron", import("@rango-dev/wallets-core/namespaces/tron").TronActions> & Record<"sui", import("@hub3js/sui").SuiActions>>]];
|
|
2
2
|
export { versions };
|
|
3
3
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,sbAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gn=Object.defineProperty;var e=(n,o)=>gn(n,"name",{value:o,configurable:!0});import{defineVersions as Io}from"@hub3js/core/utils";import{ProviderBuilder as Oo}from"@hub3js/core";import{LegacyNetworks as r}from"@rango-dev/wallets-core/legacy";import{Networks as Bn}from"@rango-dev/wallets-shared";import{solanaBlockchain as Rn,tonBlockchain as kn}from"rango-types";import{EVM_NAMESPACE as Pn,SOLANA_NAMESPACE as xn,UTXO_NAMESPACE as On,TON_NAMESPACE as In}from"@hub3js/namespaces";import{dynamicImportWithRefinedError as Nn,getNetworkInstance as P}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as _n,TransactionType as x}from"rango-types";import{DefaultSolanaSigner as An}from"@rango-dev/signer-solana";import{SignerError as En,SignerErrorCode as hn}from"rango-types";var T=class extends An{static{e(this,"OKXSolanaSigner")}constructor(o){super(o)}async signMessage(o){try{let{signature:t}=await this.provider.request({method:"signMessage",params:{message:o}});return t}catch(t){throw new En(hn.SIGN_TX_ERROR,void 0,t)}}};import{dynamicImportWithRefinedError as vn}from"@rango-dev/wallets-shared";import{SignerError as C,SignerErrorCode as R,TonChainID as Cn}from"rango-types";import{utils as B}from"@rango-dev/wallets-core/namespaces/ton";import{dynamicImportWithRefinedError as Tn}from"@rango-dev/wallets-shared";function f(n){return!!n&&n.event==="connect"&&Array.isArray(n.payload?.items)}e(f,"isTonConnectEventSuccess");function wn(n){return typeof n=="object"&&n!==null&&"name"in n&&n.name==="ton_addr"&&"address"in n&&typeof n.address=="string"}e(wn,"isTonAddressItemReply");var D;function X(n){D=n}e(X,"setEnvironments");function j(){let n=D?.tonConnectManifestUrl;if(!n)throw new Error("OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.");return n}e(j,"getTonConnectManifestUrl");var U=0;function w(){return U+=1,U.toString()}e(w,"nextTonRequestId");async function v(n){if(!f(n))return B.formatAccountsToCAIP([]);let o=n.payload.items.find(wn);if(!o)return B.formatAccountsToCAIP([]);let{Address:t}=await Tn(async()=>await import("@ton/core")),i=t.parseRaw(o.address).toString({bounceable:!1,urlSafe:!0});return B.formatAccountsToCAIP([i])}e(v,"connectEventToCAIP");function bn(n){let o=n.error.code===S?R.REJECTED_BY_USER:R.SEND_TX_ERROR;return new C(o,n.error.message,n.error)}e(bn,"toSignerError");var b=class{static{e(this,"OKXTonSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw C.UnimplementedError("signMessage")}async signAndSendTx(o){let{validUntil:t,network:i,from:p,messages:a}=o,{Address:m,Cell:h}=await vn(async()=>await import("@ton/core")),N={valid_until:t,network:i??Cn.MAINNET,...p&&{from:m.parse(p).toRawString()},messages:a.map(({stateInit:c,payload:_,...fn})=>({...fn,...c!=null&&{stateInit:c},..._!=null&&{payload:_}}))};try{let c=await this.provider.send({method:"sendTransaction",params:[JSON.stringify(N)],id:w()});if("error"in c)throw bn(c);return{hash:h.fromBase64(c.result).hash().toString("hex")}}catch(c){throw c instanceof C?c:new C(R.SEND_TX_ERROR,void 0,c)}}};import{Networks as Sn}from"@rango-dev/wallets-shared";import{SignerError as yn}from"rango-types";var y=class{static{e(this,"OKXUTXOSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw yn.UnimplementedError("signMessage")}async signAndSendTx(o){let{asset:t,psbt:i}=o;if(!i)throw new Error("No PSBT found to sign. Ensure a valid PSBT is provided.");if(t.blockchain!==Sn.BTC)throw new Error(`Signing ${t.blockchain} transaction is not implemented by the signer.`);let p=Buffer.from(i.unsignedPsbtBase64,"base64").toString("hex"),a=i.inputsToSign.flatMap(({address:m,signingIndexes:h})=>h.map(N=>({index:N,address:m})));try{let m=await this.provider.signPsbt(p,{autoFinalized:!0,toSignInputs:a});return{hash:await this.provider.pushPsbt(m)}}catch(m){throw new Error(m?.message||"Error during signing transaction")}}};async function k(n){let o=P(n,Pn),t=P(n,xn),i=P(n,On),p=P(n,In),a=new _n,{DefaultEvmSigner:m}=await Nn(async()=>await import("@rango-dev/signer-evm"));return a.registerSigner(x.EVM,new m(o)),a.registerSigner(x.SOLANA,new T(t)),a.registerSigner(x.TRANSFER,new y(i)),a.registerSigner(x.TON,new b(p)),a}e(k,"getSigners");import{EVM_NAMESPACE as W,SOLANA_NAMESPACE as K,UTXO_NAMESPACE as V,TON_NAMESPACE as H}from"@hub3js/namespaces";function d(){let{okxwallet:n,okxTonWallet:o}=window;if(!n&&!o)return null;let t=new Map;return n&&t.set(W,n),n.solana&&t.set(K,n.solana),n.bitcoin&&t.set(V,n.bitcoin),o?.tonconnect&&t.set(H,o.tonconnect),t}e(d,"okx");function F(){let n=d();if(!n)throw new Error("OKX Wallet is not injected. Please check your wallet.");return n}e(F,"getInstanceOrThrow");function u(){let o=d()?.get(W);if(!o)throw new Error("OKX Wallet not injected or EVM not enabled. Please check your wallet.");return o}e(u,"evmOKX");function g(){let o=d()?.get(K);if(!o)throw new Error("OKX Wallet not injected or Solana not enabled. Please check your wallet.");return o}e(g,"solanaOKX");function A(){let o=d()?.get(V);if(!o)throw new Error("OKX Wallet not injected or Utxo not enabled. Please check your wallet.");return o}e(A,"bitcoinOKX");function l(){let o=d()?.get(H);if(!o)throw new Error("OKX Wallet not injected or TON not enabled. Please check your wallet.");return o}e(l,"tonOKX");async function q(){let o=await A().connect();if(o.error?.message)throw new Error(o.error.message);return o}e(q,"getBitcoinAccounts");var s="okx",G=2,S=300,Mn=[r.ETHEREUM,r.BSC,r.POLYGON,r.FANTOM,r.ARBITRUM,r.OPTIMISM,r.CRONOS,r.BOBA,r.GNOSIS,r.MOONBEAM,r.MOONRIVER,r.HARMONY,r.AVAX_CCHAIN],z={name:"OKX",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",brave:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",firefox:"https://addons.mozilla.org/en-US/firefox/addon/okexwallet",homepage:"https://www.okx.com/web3"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",getSupportedChains:n=>n.filter(o=>Mn.includes(o.name))},{label:"Solana",value:"Solana",id:"SOLANA",getSupportedChains:n=>Rn(n)},{label:"BTC",value:"UTXO",id:"BTC",getSupportedChains:n=>n.filter(o=>o.name===Bn.BTC)},{label:"Ton",value:"Ton",id:"TON",getSupportedChains:n=>kn(n)}]}},{name:"signers",value:{getSigners:async()=>k(F())}}]};import{NamespaceBuilder as Ln}from"@hub3js/core";import{actions as O,builders as E,utils as Un}from"@hub3js/evm";import*as J from"@hub3js/std/builders";import{standardizeAndThrowError as Dn}from"@hub3js/std/operators";var[Xn,Y]=E.changeAccountSubscriber(u).onSwitchAccount(n=>{n.payload.length||n.preventDefault()}).format(async(n,o)=>{let t=await n.request({method:"eth_chainId"});return Un.formatAccountsToCAIP(o.filter(Boolean),t)}).build(),jn=E.connect().action(O.connect(u)).before(Xn).or(Y).or(Dn).build(),Wn=J.disconnect().before(()=>{u().disconnect()}).after(Y).build(),Kn=E.canSwitchNetwork().action(O.canSwitchNetwork()).build(),Vn=E.canEagerConnect().action(O.canEagerConnect(u)).build(),Hn=E.getChainId().action(O.getChainId(u)).build(),$=new Ln("EVM",s).action(jn).action(Wn).action(Vn).action(Kn).action(Hn).build();import{ActionBuilder as Fn,NamespaceBuilder as qn}from"@hub3js/core";import{actions as Q,builders as Z,utils as Gn}from"@hub3js/solana";import*as nn from"@hub3js/std/builders";import{standardizeAndThrowError as zn}from"@hub3js/std/operators";var[Jn,on]=Z.changeAccountSubscriber(g).onSwitchAccount(n=>{n.payload||n.preventDefault()}).format(async(n,o)=>Gn.formatAccountsToCAIP(o?[o]:[])).build(),Yn=Z.connect().action(Q.connect(g)).before(Jn).or(on).or(zn).build(),$n=nn.disconnect().before(()=>{g().disconnect()}).after(on).build(),Qn=new Fn("canEagerConnect").action(Q.canEagerConnect(g)).build(),tn=new qn("Solana",s).action(Yn).action($n).action(Qn).build();import{NamespaceBuilder as io}from"@hub3js/core";import*as rn from"@hub3js/std/builders";import{standardizeAndThrowError as co}from"@hub3js/std/operators";import{builders as cn}from"@rango-dev/wallets-core/namespaces/ton";import"@rango-dev/wallets-core/namespaces/ton";function Zn(n){return async()=>{let o=n(),t;try{t=await o.restoreConnection()}catch{}if((!t||!f(t))&&(t=await o.connect(G,{manifestUrl:j(),items:[{name:"ton_addr"}]})),!f(t))throw t.payload.code===S?new Error("User rejected the request."):new Error(`Couldn't connect to OKX TON. code: ${t.payload.code}, message: ${t.payload.message}`);let i=await v(t);if(!i.length)throw new Error("Couldn't find any TON address!");return i}}e(Zn,"connect");function no(n){return async()=>{try{let o=await n().restoreConnection();return f(o)}catch{return!1}}}e(no,"canEagerConnect");function oo(n){return async()=>{try{await n().send({method:"disconnect",params:[],id:w()})}catch{}}}e(oo,"disconnect");var I={connect:Zn,canEagerConnect:no,disconnect:oo};import{ChangeAccountSubscriberBuilder as en}from"@hub3js/std/hooks";import{utils as to}from"@rango-dev/wallets-core/namespaces/ton";var eo=e(n=>new en().getInstance(n).format(async o=>{try{let t=await o.restoreConnection();return await v(t)}catch{return to.formatAccountsToCAIP([])}}).addEventListener((o,t)=>{o.on("accountChanged",t)}).removeEventListener((o,t)=>{o.off("accountChanged",t)}),"changeAccountSubscriber"),ro=e(n=>new en().getInstance(n).onSwitchAccount((o,t)=>{o.preventDefault(),t.action("disconnect")}).format(async()=>[]).addEventListener((o,t)=>{o.on("disconnect",t)}).removeEventListener((o,t)=>{o.off("disconnect",t)}),"disconnectSubscriber"),M={changeAccountSubscriber:eo,disconnectSubscriber:ro};var[so,sn]=M.changeAccountSubscriber(l).build(),[ao,an]=M.disconnectSubscriber(l).build(),mo=cn.connect().action(I.connect(l)).before(so).before(ao).or(an).or(sn).or(co).build(),po=rn.disconnect().before(I.disconnect(l)).after(sn).after(an).build(),uo=cn.canEagerConnect().action(I.canEagerConnect(l)).build(),mn=new io("Ton",s).action(mo).action(po).action(uo).build();import{NamespaceBuilder as To}from"@hub3js/core";import*as dn from"@hub3js/std/builders";import{standardizeAndThrowError as wo}from"@hub3js/std/operators";import{CAIP_BITCOIN_CHAIN_ID as vo,utils as Co}from"@rango-dev/wallets-core/namespaces/utxo";import{builders as bo}from"@rango-dev/wallets-core/namespaces/utxo";import{ActionBuilder as lo}from"@hub3js/core";import{ChangeAccountSubscriberBuilder as fo}from"@hub3js/std/hooks";import{CAIP_BITCOIN_CHAIN_ID as go,utils as Ao}from"@rango-dev/wallets-core/namespaces/utxo";var Eo=e(n=>new fo().getInstance(n).onSwitchAccount(o=>{o.payload?.address||o.preventDefault()}).format(async(o,t)=>Ao.formatAccountsToCAIP(t?[t.address]:[],go)).addEventListener((o,t)=>o.addListener("accountChanged",t)).removeEventListener((o,t)=>o.removeListener("accountChanged",t)),"changeAccountSubscriber");function ho(n){return new lo("canEagerConnect").action(async()=>{let o=n();try{return!!(await o.getAccounts()).length}catch{return!1}})}e(ho,"canEagerConnect");var L={changeAccountSubscriber:Eo,canEagerConnect:ho};var[So,pn]=L.changeAccountSubscriber(A).build(),yo=L.canEagerConnect(A).build(),Po=bo.connect().action(async function(){let n=await q();if(!n?.address)throw new Error("Couldn't find any address!");return Co.formatAccountsToCAIP([n.address],vo)}).before(So).or(pn).or(wo).build(),xo=dn.disconnect().before(()=>{A().disconnect()}).after(pn).build(),un=new To("UTXO",s).action(Po).action(xo).action(yo).build();var ln=e(()=>new Oo(s).init(function(n,o){X(o);let[,t]=n.state();d()&&(t("installed",!0),console.debug("[okx] instance detected.",n))}).config("metadata",z).add("solana",tn).add("evm",$).add("utxo",un).add("ton",mn).build(),"buildProvider");var le=e(()=>Io().version("1.0.0",ln()).build(),"versions");export{le as versions};
|
|
1
|
+
var Dn=Object.defineProperty;var e=(n,o)=>Dn(n,"name",{value:o,configurable:!0});import{defineVersions as wt}from"@hub3js/core/utils";import{ProviderBuilder as bt}from"@hub3js/core";import{LegacyNetworks as a}from"@rango-dev/wallets-core/legacy";import{Networks as no}from"@rango-dev/wallets-shared";import{solanaBlockchain as oo,tonBlockchain as to,TransactionType as eo,tronBlockchain as ro}from"rango-types";import{EVM_NAMESPACE as Gn,SOLANA_NAMESPACE as Jn,UTXO_NAMESPACE as Yn,TON_NAMESPACE as $n,TRON_NAMESPACE as Qn}from"@hub3js/namespaces";import{dynamicImportWithRefinedError as D,getNetworkInstance as v}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as Zn,TransactionType as A}from"rango-types";import{DefaultSolanaSigner as Un}from"@rango-dev/signer-solana";import{SignerError as Wn,SignerErrorCode as jn}from"rango-types";var y=class extends Un{static{e(this,"OKXSolanaSigner")}constructor(o){super(o)}async signMessage(o){try{let{signature:t}=await this.provider.request({method:"signMessage",params:{message:o}});return t}catch(t){throw new Wn(jn.SIGN_TX_ERROR,void 0,t)}}};import{dynamicImportWithRefinedError as Hn}from"@rango-dev/wallets-shared";import{SignerError as x,SignerErrorCode as M,TonChainID as qn}from"rango-types";import{utils as R}from"@hub3js/tvm";import{dynamicImportWithRefinedError as Xn}from"@rango-dev/wallets-shared";function T(n){return!!n&&n.event==="connect"&&Array.isArray(n.payload?.items)}e(T,"isTonConnectEventSuccess");function Kn(n){return typeof n=="object"&&n!==null&&"name"in n&&n.name==="ton_addr"&&"address"in n&&typeof n.address=="string"}e(Kn,"isTonAddressItemReply");var H;function q(n){H=n}e(q,"setEnvironments");function V(){let n=H?.tonConnectManifestUrl;if(!n)throw new Error("OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.");return n}e(V,"getTonConnectManifestUrl");var K=0;function P(){return K+=1,K.toString()}e(P,"nextTonRequestId");async function O(n){if(!T(n))return R.formatAccountsToCAIP([]);let o=n.payload.items.find(Kn);if(!o)return R.formatAccountsToCAIP([]);let{Address:t}=await Xn(async()=>await import("@ton/core")),r=t.parseRaw(o.address).toString({bounceable:!1,urlSafe:!0});return R.formatAccountsToCAIP([r])}e(O,"connectEventToCAIP");function Vn(n){let o=n.error.code===N?M.REJECTED_BY_USER:M.SEND_TX_ERROR;return new x(o,n.error.message,n.error)}e(Vn,"toSignerError");var I=class{static{e(this,"OKXTonSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw x.UnimplementedError("signMessage")}async signAndSendTx(o){let{validUntil:t,network:r,from:m,messages:g}=o,{Address:i,Cell:p}=await Hn(async()=>await import("@ton/core")),E={valid_until:t,network:r??qn.MAINNET,...m&&{from:i.parse(m).toRawString()},messages:g.map(({stateInit:s,payload:h,...Ln})=>({...Ln,...s!=null&&{stateInit:s},...h!=null&&{payload:h}}))};try{let s=await this.provider.send({method:"sendTransaction",params:[JSON.stringify(E)],id:P()});if("error"in s)throw Vn(s);return{hash:p.fromBase64(s.result).hash().toString("hex")}}catch(s){throw s instanceof x?s:new x(M.SEND_TX_ERROR,void 0,s)}}};import{Networks as Fn}from"@rango-dev/wallets-shared";import{SignerError as zn}from"rango-types";var _=class{static{e(this,"OKXUTXOSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw zn.UnimplementedError("signMessage")}async signAndSendTx(o){let{asset:t,psbt:r}=o;if(!r)throw new Error("No PSBT found to sign. Ensure a valid PSBT is provided.");if(t.blockchain!==Fn.BTC)throw new Error(`Signing ${t.blockchain} transaction is not implemented by the signer.`);let m=Buffer.from(r.unsignedPsbtBase64,"base64").toString("hex"),g=r.inputsToSign.flatMap(({address:i,signingIndexes:p})=>p.map(E=>({index:E,address:i})));try{let i=await this.provider.signPsbt(m,{autoFinalized:!0,toSignInputs:g});return{hash:await this.provider.pushPsbt(i)}}catch(i){throw new Error(i?.message||"Error during signing transaction")}}};import{EVM_NAMESPACE as F,SOLANA_NAMESPACE as z,TON_NAMESPACE as G,TRON_NAMESPACE as J,UTXO_NAMESPACE as Y}from"@hub3js/namespaces";import{getInstanceOrThrow as $}from"@hub3js/sui";function d(){let{okxwallet:n,okxTonWallet:o}=window;if(!n&&!o)return null;let t=new Map;return n&&t.set(F,n),n.solana&&t.set(z,n.solana),n.bitcoin&&t.set(Y,n.bitcoin),o?.tonconnect&&t.set(G,o.tonconnect),n.tronLink&&t.set(J,n.tronLink),t}e(d,"okx");function Q(){let n=d();if(!n)throw new Error("OKX Wallet is not injected. Please check your wallet.");return n}e(Q,"getInstanceOrThrow");function l(){let o=d()?.get(F);if(!o)throw new Error("OKX Wallet not injected or EVM not enabled. Please check your wallet.");return o}e(l,"evmOKX");function b(){let o=d()?.get(z);if(!o)throw new Error("OKX Wallet not injected or Solana not enabled. Please check your wallet.");return o}e(b,"solanaOKX");function w(){let o=d()?.get(Y);if(!o)throw new Error("OKX Wallet not injected or Utxo not enabled. Please check your wallet.");return o}e(w,"bitcoinOKX");function f(){let o=d()?.get(G);if(!o)throw new Error("OKX Wallet not injected or TON not enabled. Please check your wallet.");return o}e(f,"tonOKX");function S(){let o=d()?.get(J);if(!o)throw new Error("OKX Wallet not injected or Tron not enabled. Please check your wallet.");return o}e(S,"tronOKX");function Z(){try{return $(u)}catch{return null}}e(Z,"suiWalletInstance");function nn(){return $(u)}e(nn,"suiWalletInstanceOrThrow");async function on(){let o=await w().connect();if(o.error?.message)throw new Error(o.error.message);return o}e(on,"getBitcoinAccounts");function L(n){if(typeof n!="object"||n===null)return!1;let o=n;return typeof o.message=="object"&&o.message!==null&&typeof o.message.action=="string"}e(L,"isOkxTronMessageEvent");async function U(n){let o=v(n,Gn),t=v(n,Jn),r=v(n,Yn),m=v(n,$n),g=v(n,Qn),i=new Zn,{DefaultEvmSigner:p}=await D(async()=>await import("@rango-dev/signer-evm")),{DefaultTronSigner:E}=await D(async()=>await import("@rango-dev/signer-tron"));i.registerSigner(A.EVM,new p(o)),i.registerSigner(A.SOLANA,new y(t)),i.registerSigner(A.TRANSFER,new _(r)),i.registerSigner(A.TON,new I(m)),i.registerSigner(A.TRON,new E(g));let s=Z();if(s){let{DefaultSuiSigner:h}=await D(async()=>await import("@rango-dev/signer-sui"));i.registerSigner(A.SUI,new h(s))}return i}e(U,"getSigners");var c="okx",tn=2,N=300,en=200,rn=4001,u="OKX Wallet",io=[a.ETHEREUM,a.BSC,a.POLYGON,a.FANTOM,a.ARBITRUM,a.OPTIMISM,a.CRONOS,a.BOBA,a.GNOSIS,a.MOONBEAM,a.MOONRIVER,a.HARMONY,a.AVAX_CCHAIN],cn={name:"OKX",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",brave:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",firefox:"https://addons.mozilla.org/en-US/firefox/addon/okexwallet",homepage:"https://www.okx.com/web3"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",getSupportedChains:n=>n.filter(o=>io.includes(o.name))},{label:"Solana",value:"Solana",id:"SOLANA",getSupportedChains:n=>oo(n)},{label:"BTC",value:"UTXO",id:"BTC",getSupportedChains:n=>n.filter(o=>o.name===no.BTC)},{label:"Ton",value:"Ton",id:"TON",getSupportedChains:n=>to(n)},{label:"Tron",value:"Tron",id:"TRON",getSupportedChains:n=>ro(n)},{label:"Sui",value:"Sui",id:"SUI",getSupportedChains:n=>n.filter(o=>o.type===eo.SUI)}]}},{name:"signers",value:{getSigners:async()=>U(Q())}}]};import{NamespaceBuilder as co}from"@hub3js/core";import{actions as B,builders as C,utils as so}from"@hub3js/evm";import*as sn from"@hub3js/std/builders";import{standardizeAndThrowError as ao}from"@hub3js/std/operators";var[mo,an]=C.changeAccountSubscriber(l).onSwitchAccount(n=>{n.payload.length||n.preventDefault()}).format(async(n,o)=>{let t=await n.request({method:"eth_chainId"});return so.formatAccountsToCAIP(o.filter(Boolean),t)}).build(),uo=C.connect().action(B.connect(l)).before(mo).or(an).or(ao).build(),po=sn.disconnect().before(()=>{l().disconnect()}).after(an).build(),lo=C.canSwitchNetwork().action(B.canSwitchNetwork()).build(),fo=C.canEagerConnect().action(B.canEagerConnect(l)).build(),Ao=C.getChainId().action(B.getChainId(l)).build(),mn=new co("EVM",c).action(uo).action(po).action(fo).action(lo).action(Ao).build();import{ActionBuilder as go,NamespaceBuilder as Eo}from"@hub3js/core";import{actions as dn,builders as un,utils as ho}from"@hub3js/solana";import*as pn from"@hub3js/std/builders";import{standardizeAndThrowError as To}from"@hub3js/std/operators";var[bo,ln]=un.changeAccountSubscriber(b).onSwitchAccount(n=>{n.payload||n.preventDefault()}).format(async(n,o)=>ho.formatAccountsToCAIP(o?[o]:[])).build(),wo=un.connect().action(dn.connect(b)).before(bo).or(ln).or(To).build(),So=pn.disconnect().before(()=>{b().disconnect()}).after(ln).build(),vo=new go("canEagerConnect").action(dn.canEagerConnect(b)).build(),fn=new Eo("Solana",c).action(wo).action(So).action(vo).build();import{NamespaceBuilder as No}from"@hub3js/core";import*as gn from"@hub3js/std/builders";import{standardizeAndThrowError as _o}from"@hub3js/std/operators";import{builders as En}from"@hub3js/tvm";import"@hub3js/tvm";function Co(n){return async()=>{let o=n(),t;try{t=await o.restoreConnection()}catch{}if((!t||!T(t))&&(t=await o.connect(tn,{manifestUrl:V(),items:[{name:"ton_addr"}]})),!T(t))throw t.payload.code===N?new Error("User rejected the request."):new Error(`Couldn't connect to OKX TON. code: ${t.payload.code}, message: ${t.payload.message}`);let r=await O(t);if(!r.length)throw new Error("Couldn't find any TON address!");return r}}e(Co,"connect");function yo(n){return async()=>{try{let o=await n().restoreConnection();return T(o)}catch{return!1}}}e(yo,"canEagerConnect");function Po(n){return async()=>{try{await n().send({method:"disconnect",params:[],id:P()})}catch{}}}e(Po,"disconnect");var k={connect:Co,canEagerConnect:yo,disconnect:Po};import{ChangeAccountSubscriberBuilder as An}from"@hub3js/std/hooks";import{utils as Oo}from"@hub3js/tvm";var xo=e(n=>new An().getInstance(n).format(async o=>{try{let t=await o.restoreConnection();return await O(t)}catch{return Oo.formatAccountsToCAIP([])}}).addEventListener((o,t)=>{o.on("accountChanged",t)}).removeEventListener((o,t)=>{o.off("accountChanged",t)}),"changeAccountSubscriber"),Io=e(n=>new An().getInstance(n).onSwitchAccount((o,t)=>{o.preventDefault(),t.action("disconnect")}).format(async()=>[]).addEventListener((o,t)=>{o.on("disconnect",t)}).removeEventListener((o,t)=>{o.off("disconnect",t)}),"disconnectSubscriber"),W={changeAccountSubscriber:xo,disconnectSubscriber:Io};var[Bo,hn]=W.changeAccountSubscriber(f).build(),[ko,Tn]=W.disconnectSubscriber(f).build(),Ro=En.connect().action(k.connect(f)).before(Bo).before(ko).or(Tn).or(hn).or(_o).build(),Mo=gn.disconnect().before(k.disconnect(f)).after(hn).after(Tn).build(),Lo=En.canEagerConnect().action(k.canEagerConnect(f)).build(),bn=new No("Ton",c).action(Ro).action(Mo).action(Lo).build();import{NamespaceBuilder as Ho}from"@hub3js/core";import*as Sn from"@hub3js/std/builders";import{standardizeAndThrowError as qo}from"@hub3js/std/operators";import"@rango-dev/wallets-core/namespaces/tron";import{builders as vn}from"@rango-dev/wallets-core/namespaces/tron";import{utils as Do}from"@rango-dev/wallets-core/namespaces/tron";var Uo=e(async()=>{let n=S(),o=await n.request({method:"tron_requestAccounts"});if(o?.code&&o.code!==en)throw o.code===rn?new Error("User rejected the request."):new Error(o.message??"Failed to connect to OKX Wallet Tron.");return Do.formatAccountsToCAIP([n.tronWeb.defaultAddress.base58])},"connect"),Wo=e(async()=>{try{return!!S().ready}catch{return!1}},"canEagerConnect"),j={connect:Uo,canEagerConnect:Wo};import{ChangeAccountSubscriberBuilder as jo}from"@hub3js/std/hooks";import{utils as Xo}from"@rango-dev/wallets-core/namespaces/tron";var Ko=e(n=>new jo().getInstance(n).onSwitchAccount((o,t)=>{let r=o.payload?.data;if(!L(r)){o.preventDefault();return}let{action:m}=r.message;if(m==="disconnect"){o.preventDefault(),t.action("disconnect");return}(m!=="accountsChanged"||typeof r.message.data?.address!="string")&&o.preventDefault()}).format(async(o,t)=>{let r=t.data,m=L(r)&&r.message.action==="accountsChanged"?r.message.data?.address:void 0;if(typeof m!="string")throw new Error("No Tron address received from OKX Wallet.");return Xo.formatAccountsToCAIP([m])}).addEventListener((o,t)=>{window.addEventListener("message",t)}).removeEventListener((o,t)=>{window.removeEventListener("message",t)}),"changeAccountSubscriber"),wn={changeAccountSubscriber:Ko};var[Vo,Cn]=wn.changeAccountSubscriber(S).build(),Fo=vn.connect().action(j.connect).before(Vo).or(Cn).or(qo).build(),zo=vn.canEagerConnect().action(j.canEagerConnect).build(),Go=Sn.disconnect().after(Cn).build(),yn=new Ho("Tron",c).action(Fo).action(Go).action(zo).build();import{NamespaceBuilder as Yo}from"@hub3js/core";import*as On from"@hub3js/std/builders";import{standardizeAndThrowError as $o}from"@hub3js/std/operators";import{actions as Qo,builders as xn,hooks as Zo}from"@hub3js/sui";function Jo(n){let o;return[t=>{let r=n();if(!r)throw new Error("Trying to subscribe to your Sui wallet, but seems its instance is not available.");o=r.features["standard:events"].on("disconnect",()=>{t.action("disconnect")})},(t,r)=>(typeof o=="function"&&o(),r)]}e(Jo,"disconnectSubscriber");var Pn={disconnectSubscriber:Jo};var[nt,In]=Zo.changeAccountSubscriber({name:u}),[ot,Nn]=Pn.disconnectSubscriber(nn),tt=xn.canEagerConnect().action(Qo.canEagerConnect({name:u})).build(),et=xn.connect({name:u}).before(nt).before(ot).or(In).or(Nn).or($o).build(),rt=On.disconnect().after(In).after(Nn).build(),_n=new Yo("Sui",c).action(et).action(rt).action(tt).build();import{NamespaceBuilder as ut}from"@hub3js/core";import*as Bn from"@hub3js/std/builders";import{standardizeAndThrowError as pt}from"@hub3js/std/operators";import{CAIP_BITCOIN_CHAIN_ID as lt,utils as ft}from"@rango-dev/wallets-core/namespaces/utxo";import{builders as At}from"@rango-dev/wallets-core/namespaces/utxo";import{ActionBuilder as it}from"@hub3js/core";import{ChangeAccountSubscriberBuilder as ct}from"@hub3js/std/hooks";import{CAIP_BITCOIN_CHAIN_ID as st,utils as at}from"@rango-dev/wallets-core/namespaces/utxo";var mt=e(n=>new ct().getInstance(n).onSwitchAccount(o=>{o.payload?.address||o.preventDefault()}).format(async(o,t)=>at.formatAccountsToCAIP(t?[t.address]:[],st)).addEventListener((o,t)=>o.addListener("accountChanged",t)).removeEventListener((o,t)=>o.removeListener("accountChanged",t)),"changeAccountSubscriber");function dt(n){return new it("canEagerConnect").action(async()=>{let o=n();try{return!!(await o.getAccounts()).length}catch{return!1}})}e(dt,"canEagerConnect");var X={changeAccountSubscriber:mt,canEagerConnect:dt};var[gt,kn]=X.changeAccountSubscriber(w).build(),Et=X.canEagerConnect(w).build(),ht=At.connect().action(async function(){let n=await on();if(!n?.address)throw new Error("Couldn't find any address!");return ft.formatAccountsToCAIP([n.address],lt)}).before(gt).or(kn).or(pt).build(),Tt=Bn.disconnect().before(()=>{w().disconnect()}).after(kn).build(),Rn=new ut("UTXO",c).action(ht).action(Tt).action(Et).build();var Mn=e(()=>new bt(c).init(function(n,o){q(o);let[,t]=n.state();d()&&(t("installed",!0),console.debug("[okx] instance detected.",n))}).config("metadata",cn).add("solana",fn).add("evm",mn).add("utxo",Rn).add("ton",bn).add("tron",yn).add("sui",_n).build(),"buildProvider");var Ur=e(()=>wt().version("1.0.0",Mn()).build(),"versions");export{Ur 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
|
-
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/signers/solana.ts", "../src/signers/ton.ts", "../src/namespaces/ton/utils.ts", "../src/signers/utxo.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/namespaces/solana.ts", "../src/namespaces/ton/ton.ts", "../src/actions/ton.ts", "../src/builders/ton.ts", "../src/namespaces/utxo.ts", "../src/builders/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 };\n", "import type { Environments } from './namespaces/ton/types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { solana } from './namespaces/solana.js';\nimport { ton } from './namespaces/ton/ton.js';\nimport { setEnvironments } from './namespaces/ton/utils.js';\nimport { utxo } from './namespaces/utxo.js';\nimport { okx as okxInstance } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments?: Environments) {\n setEnvironments(environments);\n const [, setState] = context.state();\n\n if (okxInstance()) {\n setState('installed', true);\n console.debug('[okx] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('solana', solana)\n .add('evm', evm)\n .add('utxo', utxo)\n .add('ton', ton)\n\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\nimport { Networks } from '@rango-dev/wallets-shared';\nimport {\n type BlockchainMeta,\n solanaBlockchain,\n tonBlockchain,\n type TransferBlockchainMeta,\n} from 'rango-types';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'okx';\nexport const TON_CONNECT_PROTOCOL_VERSION = 2;\nexport const TON_CONNECT_USER_REJECTED_CODE = 300;\n\nexport const OKX_WALLET_SUPPORTED_CHAINS = [\n LegacyNetworks.ETHEREUM,\n LegacyNetworks.BSC,\n LegacyNetworks.POLYGON,\n LegacyNetworks.FANTOM,\n LegacyNetworks.ARBITRUM,\n LegacyNetworks.OPTIMISM,\n LegacyNetworks.CRONOS,\n LegacyNetworks.BOBA,\n LegacyNetworks.GNOSIS,\n LegacyNetworks.MOONBEAM,\n LegacyNetworks.MOONRIVER,\n LegacyNetworks.HARMONY,\n LegacyNetworks.AVAX_CCHAIN,\n];\n\nexport const metadata: ProviderMetadata = {\n name: 'OKX',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n brave:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n firefox: 'https://addons.mozilla.org/en-US/firefox/addon/okexwallet',\n homepage: 'https://www.okx.com/web3',\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 getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter((blockchainMeta) =>\n OKX_WALLET_SUPPORTED_CHAINS.includes(\n blockchainMeta.name as LegacyNetworks\n )\n ),\n },\n {\n label: 'Solana',\n value: 'Solana',\n id: 'SOLANA',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n solanaBlockchain(allBlockchains),\n },\n {\n label: 'BTC',\n value: 'UTXO',\n id: 'BTC',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (chain): chain is TransferBlockchainMeta =>\n chain.name === Networks.BTC\n ),\n },\n {\n label: 'Ton',\n value: 'Ton',\n id: 'TON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tonBlockchain(allBlockchains),\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 SOLANA_NAMESPACE,\n UTXO_NAMESPACE,\n TON_NAMESPACE,\n} from '@hub3js/namespaces';\nimport {\n dynamicImportWithRefinedError,\n getNetworkInstance,\n} from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { OKXSolanaSigner } from './signers/solana.js';\nimport { OKXTonSigner } from './signers/ton.js';\nimport { OKXUTXOSigner } from './signers/utxo.js';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = getNetworkInstance(provider, EVM_NAMESPACE);\n const solProvider = getNetworkInstance(provider, SOLANA_NAMESPACE);\n const utxoProvider = getNetworkInstance(provider, UTXO_NAMESPACE);\n const tonProvider = getNetworkInstance(provider, TON_NAMESPACE);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-evm')\n );\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n signers.registerSigner(TxType.SOLANA, new OKXSolanaSigner(solProvider));\n signers.registerSigner(TxType.TRANSFER, new OKXUTXOSigner(utxoProvider));\n signers.registerSigner(TxType.TON, new OKXTonSigner(tonProvider));\n\n return signers;\n}\n", "import {\n DefaultSolanaSigner,\n type SolanaExternalProvider,\n} from '@rango-dev/signer-solana';\nimport { SignerError, SignerErrorCode } from 'rango-types';\n\nexport class OKXSolanaSigner extends DefaultSolanaSigner {\n constructor(provider: SolanaExternalProvider) {\n super(provider);\n }\n\n async signMessage(msg: string): Promise<string> {\n try {\n const { signature } = await this.provider.request({\n method: 'signMessage',\n params: {\n message: msg,\n },\n });\n return signature;\n } catch (error) {\n throw new SignerError(SignerErrorCode.SIGN_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n TonConnectWalletResponseError,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { GenericSigner, TonTransaction } from 'rango-types';\n\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\nimport { SignerError, SignerErrorCode, TonChainID } from 'rango-types';\n\nimport { TON_CONNECT_USER_REJECTED_CODE } from '../constants.js';\nimport { nextTonRequestId } from '../namespaces/ton/utils.js';\n\nfunction toSignerError(response: TonConnectWalletResponseError): SignerError {\n const code =\n response.error.code === TON_CONNECT_USER_REJECTED_CODE\n ? SignerErrorCode.REJECTED_BY_USER\n : SignerErrorCode.SEND_TX_ERROR;\n return new SignerError(code, response.error.message, response.error);\n}\n\nexport class OKXTonSigner implements GenericSigner<TonTransaction> {\n private provider: TonProviderApi;\n\n constructor(provider: TonProviderApi) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: TonTransaction): Promise<{ hash: string }> {\n const { validUntil, network, from, messages } = tx;\n\n const { Address, Cell } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n\n const transactionPayload = {\n valid_until: validUntil,\n network: network ?? TonChainID.MAINNET,\n ...(from && { from: Address.parse(from).toRawString() }),\n messages: messages.map(({ stateInit, payload, ...message }) => ({\n ...message,\n ...(stateInit != null && { stateInit }),\n ...(payload != null && { payload }),\n })),\n };\n\n try {\n const response = await this.provider.send({\n method: 'sendTransaction',\n params: [JSON.stringify(transactionPayload)],\n id: nextTonRequestId(),\n });\n\n if ('error' in response) {\n throw toSignerError(response);\n }\n\n const hash = Cell.fromBase64(response.result).hash().toString('hex');\n return { hash };\n } catch (error) {\n if (error instanceof SignerError) {\n throw error;\n }\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n Environments,\n TonAddressItemReply,\n TonConnectEvent,\n TonConnectEventSuccess,\n} from './types.js';\nimport type { CaipAccount } from '@rango-dev/wallets-core/namespaces/common';\n\nimport { utils as tonCoreUtils } from '@rango-dev/wallets-core/namespaces/ton';\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\n\nexport function isTonConnectEventSuccess(\n event: TonConnectEvent\n): event is TonConnectEventSuccess {\n return (\n !!event && event.event === 'connect' && Array.isArray(event.payload?.items)\n );\n}\n\nexport function isTonAddressItemReply(\n item: unknown\n): item is TonAddressItemReply {\n return (\n typeof item === 'object' &&\n item !== null &&\n 'name' in item &&\n item.name === 'ton_addr' &&\n 'address' in item &&\n typeof item.address === 'string'\n );\n}\n\nlet environments: Environments | undefined;\n\nexport function setEnvironments(env?: Environments) {\n environments = env;\n}\n\nexport function getTonConnectManifestUrl(): string {\n const manifestUrl = environments?.tonConnectManifestUrl;\n if (!manifestUrl) {\n throw new Error(\n 'OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.'\n );\n }\n return manifestUrl;\n}\n\nlet tonRequestId = 0;\n\n// TonConnect requires a unique string `id` on every request sent to the bridge.\nexport function nextTonRequestId(): string {\n tonRequestId += 1;\n return tonRequestId.toString();\n}\n\n// Convert a `ConnectEvent`'s raw `<workchain>:<hex>` address to user-friendly CAIP.\nexport async function connectEventToCAIP(\n connectEvent: TonConnectEvent\n): Promise<CaipAccount[]> {\n if (!isTonConnectEventSuccess(connectEvent)) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const addressItem = connectEvent.payload.items.find(isTonAddressItemReply);\n if (!addressItem) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const { Address } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n const userFriendlyAddress = Address.parseRaw(addressItem.address).toString({\n bounceable: false,\n urlSafe: true,\n });\n\n return tonCoreUtils.formatAccountsToCAIP([userFriendlyAddress]);\n}\n", "import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/utxo';\nimport type { GenericSigner, Transfer } from 'rango-types';\n\nimport { Networks } from '@rango-dev/wallets-shared';\nimport { SignerError } from 'rango-types';\n\nexport class OKXUTXOSigner 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 (asset.blockchain !== Networks.BTC) {\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 try {\n // 3. Sign (& auto-finalize)\n const signedPsbtHex = await this.provider.signPsbt(psbtHex, {\n autoFinalized: true,\n toSignInputs,\n });\n\n // 4. Push signed psbt\n const transactionHash = await this.provider.pushPsbt(signedPsbtHex);\n\n return { hash: transactionHash };\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}\n", "import type { TonProviderApi } from './namespaces/ton/types.js';\nimport type { OkxBtcAddress, Provider } from './types.js';\nimport type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';\nimport type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';\nimport type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport {\n EVM_NAMESPACE,\n SOLANA_NAMESPACE,\n UTXO_NAMESPACE,\n TON_NAMESPACE,\n} from '@hub3js/namespaces';\n\nexport function okx(): Provider | null {\n const { okxwallet, okxTonWallet } = window;\n if (!okxwallet && !okxTonWallet) {\n return null;\n }\n const instances: Provider = new Map();\n if (okxwallet) {\n instances.set(EVM_NAMESPACE, okxwallet);\n }\n if (okxwallet.solana) {\n instances.set(SOLANA_NAMESPACE, okxwallet.solana);\n }\n if (okxwallet.bitcoin) {\n instances.set(UTXO_NAMESPACE, okxwallet.bitcoin);\n }\n if (okxTonWallet?.tonconnect) {\n instances.set(TON_NAMESPACE, okxTonWallet.tonconnect);\n }\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = okx();\n\n if (!instances) {\n throw new Error('OKX Wallet is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmOKX(): EvmProviderApi {\n const instances = okx();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'OKX Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance as EvmProviderApi;\n}\n\nexport function solanaOKX(): SolanaProviderApi {\n const instance = okx();\n const solanaInstance = instance?.get(SOLANA_NAMESPACE);\n\n if (!solanaInstance) {\n throw new Error(\n 'OKX Wallet not injected or Solana not enabled. Please check your wallet.'\n );\n }\n\n return solanaInstance;\n}\nexport function bitcoinOKX(): UtxoProviderApi {\n const instance = okx();\n const bitcoinInstance = instance?.get(UTXO_NAMESPACE);\n\n if (!bitcoinInstance) {\n throw new Error(\n 'OKX Wallet not injected or Utxo not enabled. Please check your wallet.'\n );\n }\n\n return bitcoinInstance;\n}\n\nexport function tonOKX(): TonProviderApi {\n const instance = okx();\n const tonInstance = instance?.get(TON_NAMESPACE);\n\n if (!tonInstance) {\n throw new Error(\n 'OKX Wallet not injected or TON not enabled. Please check your wallet.'\n );\n }\n\n return tonInstance as TonProviderApi;\n}\n\nexport async function getBitcoinAccounts(): Promise<OkxBtcAddress> {\n const instance = bitcoinOKX();\n const requestResult = await instance.connect();\n\n if (requestResult.error?.message) {\n throw new Error(requestResult.error.message);\n }\n\n return requestResult;\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(evmOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload.length) {\n event.preventDefault();\n }\n })\n .format(async (instance, event) => {\n const chainId = await instance.request({ method: 'eth_chainId' });\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event.filter(Boolean), chainId);\n })\n .build();\nconst connect = builders\n .connect()\n .action(actions.connect(evmOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .before(() => {\n evmOKX().disconnect();\n })\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(evmOKX))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmOKX))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import type { SolanaActions } from '@hub3js/solana';\n\nimport { ActionBuilder, NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/solana';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { solanaOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(solanaOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event ? [event] : []);\n })\n .build();\n\nconst connect = builders\n .connect()\n .action(actions.connect(solanaOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SolanaActions>()\n .before(() => {\n solanaOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst canEagerConnect = new ActionBuilder<SolanaActions, 'canEagerConnect'>(\n 'canEagerConnect'\n)\n .action(actions.canEagerConnect(solanaOKX))\n .build();\n\nconst solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { solana };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport {\n builders,\n type TonActions,\n} from '@rango-dev/wallets-core/namespaces/ton';\n\nimport { tonActions } from '../../actions/ton.js';\nimport { tonBuilders } from '../../builders/ton.js';\nimport { WALLET_ID } from '../../constants.js';\nimport { tonOKX } from '../../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tonBuilders\n .changeAccountSubscriber(tonOKX)\n .build();\n\nconst [walletDisconnectSubscriber, walletDisconnectCleanup] = tonBuilders\n .disconnectSubscriber(tonOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tonActions.connect(tonOKX))\n .before(changeAccountSubscriber)\n .before(walletDisconnectSubscriber)\n .or(walletDisconnectCleanup)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TonActions>()\n .before(tonActions.disconnect(tonOKX))\n .after(changeAccountCleanup)\n .after(walletDisconnectCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tonActions.canEagerConnect(tonOKX))\n .build();\n\nconst ton = new NamespaceBuilder<TonActions>('Ton', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { ton };\n", "import type {\n TonConnectEvent,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { Context, FunctionWithContext } from '@hub3js/core';\n\nimport { type TonActions } from '@rango-dev/wallets-core/namespaces/ton';\n\nimport {\n TON_CONNECT_PROTOCOL_VERSION,\n TON_CONNECT_USER_REJECTED_CODE,\n} from '../constants.js';\nimport {\n connectEventToCAIP,\n getTonConnectManifestUrl,\n isTonConnectEventSuccess,\n nextTonRequestId,\n} from '../namespaces/ton/utils.js';\n\nexport function connect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['connect'], Context> {\n return async () => {\n const instance = getInstance();\n\n /*\n * If the dApp was approved before, `restoreConnection` resolves the current\n * session without prompting the user; otherwise fall back to a fresh\n * connect request.\n */\n let connectEvent: TonConnectEvent | undefined;\n try {\n connectEvent = await instance.restoreConnection();\n } catch {\n // No restorable session; a fresh connect request is made below.\n }\n\n if (!connectEvent || !isTonConnectEventSuccess(connectEvent)) {\n connectEvent = await instance.connect(TON_CONNECT_PROTOCOL_VERSION, {\n manifestUrl: getTonConnectManifestUrl(),\n items: [{ name: 'ton_addr' }],\n });\n }\n\n if (!isTonConnectEventSuccess(connectEvent)) {\n // The bridge reports a user-cancelled prompt as a `connect_error` event.\n if (connectEvent.payload.code === TON_CONNECT_USER_REJECTED_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n `Couldn't connect to OKX TON. code: ${connectEvent.payload.code}, message: ${connectEvent.payload.message}`\n );\n }\n\n const accounts = await connectEventToCAIP(connectEvent);\n if (!accounts.length) {\n throw new Error(\"Couldn't find any TON address!\");\n }\n\n return accounts;\n };\n}\n\nexport function canEagerConnect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['canEagerConnect'], Context> {\n return async () => {\n /*\n * Auto connect may run this before the wallet is injected; it should never\n * throw.\n */\n try {\n const connectEvent = await getInstance().restoreConnection();\n return isTonConnectEventSuccess(connectEvent);\n } catch {\n return false;\n }\n };\n}\n\nexport function disconnect(getInstance: () => TonProviderApi) {\n return async () => {\n /*\n * Revoking the session on the wallet side is best effort; local state\n * cleanup should proceed even if it fails.\n */\n try {\n await getInstance().send({\n method: 'disconnect',\n params: [],\n id: nextTonRequestId(),\n });\n } catch {\n // ignore\n }\n };\n}\n\nexport const tonActions = { connect, canEagerConnect, disconnect };\n", "import type { TonProviderApi } from '../namespaces/ton/types.js';\n\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport { type TonActions, utils } from '@rango-dev/wallets-core/namespaces/ton';\n\nimport { connectEventToCAIP } from '../namespaces/ton/utils.js';\n\n/*\n * OKX emits its non-standard `accountChanged` event without a documented\n * payload, so the switched address can't be read from the event. Because the\n * bridge is standard TON Connect, `format` re-reads the active account from the\n * instance via `restoreConnection` instead\n */\nexport const changeAccountSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .format(async (instance) => {\n try {\n const connectEvent = await instance.restoreConnection();\n return await connectEventToCAIP(connectEvent);\n } catch {\n // No active session after the switch \u2014 treat as disconnected.\n return utils.formatAccountsToCAIP([]);\n }\n })\n .addEventListener((instance, callback) => {\n instance.on('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('accountChanged', callback);\n });\n\nexport const disconnectSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n event.preventDefault();\n void context.action('disconnect');\n })\n .format(async () => [])\n .addEventListener((instance, callback) => {\n instance.on('disconnect', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('disconnect', callback);\n });\n\nexport const tonBuilders = { changeAccountSubscriber, disconnectSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\nimport { builders } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { utxoBuilders } from '../builders/utxo.js';\nimport { WALLET_ID } from '../constants.js';\nimport { bitcoinOKX, getBitcoinAccounts } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = utxoBuilders\n .changeAccountSubscriber(bitcoinOKX)\n .build();\n\nconst canEagerConnect = utxoBuilders.canEagerConnect(bitcoinOKX).build();\n\nconst connect = builders\n .connect()\n .action(async function () {\n const accountsResult = await getBitcoinAccounts();\n\n if (!accountsResult?.address) {\n throw new Error(\"Couldn't find any address!\");\n }\n return utils.formatAccountsToCAIP(\n [accountsResult.address],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<UtxoActions>()\n .before(() => {\n bitcoinOKX().disconnect();\n })\n .after(changeAccountCleanup)\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 { OkxBtcAddress } from '../types.js';\n\nimport { ActionBuilder } from '@hub3js/core';\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n type ProviderAPI,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<OkxBtcAddress, ProviderAPI, UtxoActions>()\n .getInstance(getInstance)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload?.address) {\n event.preventDefault();\n }\n })\n\n .format(async (_, event) => {\n return utils.formatAccountsToCAIP(\n event ? [event.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\nfunction canEagerConnect(getInstance: () => ProviderAPI) {\n return new ActionBuilder<UtxoActions, 'canEagerConnect'>(\n 'canEagerConnect'\n ).action(async () => {\n const instance = getInstance();\n try {\n const accounts = await instance.getAccounts();\n return !!accounts.length;\n } catch {\n return false;\n }\n });\n}\n\nexport const utxoBuilders = { changeAccountSubscriber, canEagerConnect };\n"],
|
|
5
|
-
"mappings": "iFAAA,OAAS,kBAAAA,OAAsB,qBCE/B,OAAS,mBAAAC,OAAuB,eCAhC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,YAAAC,OAAgB,4BACzB,OAEE,oBAAAC,GACA,iBAAAC,OAEK,cCNP,OACE,iBAAAC,GACA,oBAAAC,GACA,kBAAAC,GACA,iBAAAC,OACK,qBACP,OACE,iCAAAC,GACA,sBAAAC,MACK,4BACP,OAAS,wBAAAC,GAAsB,mBAAmBC,MAAc,cCbhE,OACE,uBAAAC,OAEK,2BACP,OAAS,eAAAC,GAAa,mBAAAC,OAAuB,cAEtC,IAAMC,EAAN,cAA8BC,EAAoB,CANzD,MAMyD,CAAAC,EAAA,wBACvD,YAAYC,EAAkC,CAC5C,MAAMA,CAAQ,CAChB,CAEA,MAAM,YAAYC,EAA8B,CAC9C,GAAI,CACF,GAAM,CAAE,UAAAC,CAAU,EAAI,MAAM,KAAK,SAAS,QAAQ,CAChD,OAAQ,cACR,OAAQ,CACN,QAASD,CACX,CACF,CAAC,EACD,OAAOC,CACT,OAASC,EAAO,CACd,MAAM,IAAIC,GAAYC,GAAgB,cAAe,OAAWF,CAAK,CACvE,CACF,CACF,EClBA,OAAS,iCAAAG,OAAqC,4BAC9C,OAAS,eAAAC,EAAa,mBAAAC,EAAiB,cAAAC,OAAkB,cCCzD,OAAS,SAASC,MAAoB,yCACtC,OAAS,iCAAAC,OAAqC,4BAEvC,SAASC,EACdC,EACiC,CACjC,MACE,CAAC,CAACA,GAASA,EAAM,QAAU,WAAa,MAAM,QAA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IH,EAAQ,MAAM,EAE/BI,EAAY,IACdD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,2BAA4BH,CAAO,EAErD,CAAC,EACA,OAAO,WAAYK,CAAQ,EAC3B,IAAI,SAAUC,EAAM,EACpB,IAAI,MAAOC,CAAG,EACd,IAAI,OAAQC,EAAI,EAChB,IAAI,MAAOC,EAAG,EAEd,MAAM,EAjBW,iBDRtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EAAE,QAAQ,QAASC,GAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
-
"names": ["defineVersions", "ProviderBuilder", "LegacyNetworks", "Networks", "solanaBlockchain", "tonBlockchain", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "UTXO_NAMESPACE", "TON_NAMESPACE", "dynamicImportWithRefinedError", "getNetworkInstance", "DefaultSignerFactory", "TxType", "DefaultSolanaSigner", "SignerError", "SignerErrorCode", "OKXSolanaSigner", "DefaultSolanaSigner", "__name", "provider", "msg", "signature", "error", "SignerError", "SignerErrorCode", "dynamicImportWithRefinedError", "SignerError", "SignerErrorCode", "TonChainID", "tonCoreUtils", "dynamicImportWithRefinedError", "isTonConnectEventSuccess", "event", "__name", "isTonAddressItemReply", "item", "environments", "setEnvironments", "env", "getTonConnectManifestUrl", "manifestUrl", "tonRequestId", "nextTonRequestId", "connectEventToCAIP", "connectEvent", "tonCoreUtils", "addressItem", "Address", "dynamicImportWithRefinedError", "userFriendlyAddress", "toSignerError", "response", "code", "TON_CONNECT_USER_REJECTED_CODE", "SignerErrorCode", "SignerError", "__name", "OKXTonSigner", "provider", "tx", "validUntil", "network", "from", "messages", "Address", "Cell", "dynamicImportWithRefinedError", "transactionPayload", "TonChainID", "stateInit", "payload", "message", "nextTonRequestId", "error", "Networks", "SignerError", "OKXUTXOSigner", "__name", "provider", "SignerError", "tx", "asset", "psbt", "Networks", "psbtHex", "toSignInputs", "address", "signingIndexes", "index", "signedPsbtHex", "error", "
|
|
3
|
+
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/signers/solana.ts", "../src/signers/ton.ts", "../src/namespaces/ton/utils.ts", "../src/signers/utxo.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/namespaces/solana.ts", "../src/namespaces/ton/ton.ts", "../src/actions/ton.ts", "../src/builders/ton.ts", "../src/namespaces/tron.ts", "../src/actions/tron.ts", "../src/builders/tron.ts", "../src/namespaces/sui.ts", "../src/hooks/sui.ts", "../src/namespaces/utxo.ts", "../src/builders/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 };\n", "import type { Environments } from './namespaces/ton/types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { solana } from './namespaces/solana.js';\nimport { ton } from './namespaces/ton/ton.js';\nimport { setEnvironments } from './namespaces/ton/utils.js';\nimport { tron } from './namespaces/tron.js';\nimport { sui } from './namespaces/sui.js';\nimport { utxo } from './namespaces/utxo.js';\nimport { okx as okxInstance } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments?: Environments) {\n setEnvironments(environments);\n const [, setState] = context.state();\n\n if (okxInstance()) {\n setState('installed', true);\n console.debug('[okx] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('solana', solana)\n .add('evm', evm)\n .add('utxo', utxo)\n .add('ton', ton)\n .add('tron', tron)\n .add('sui', sui)\n\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\nimport { Networks } from '@rango-dev/wallets-shared';\nimport {\n type BlockchainMeta,\n solanaBlockchain,\n tonBlockchain,\n type SuiBlockchainMeta,\n TransactionType,\n type TransferBlockchainMeta,\n tronBlockchain,\n} from 'rango-types';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'okx';\nexport const TON_CONNECT_PROTOCOL_VERSION = 2;\nexport const TON_CONNECT_USER_REJECTED_CODE = 300;\nexport const TRON_OK_REQUEST_CODE = 200;\n// EIP-1193 user-rejected-request code returned by `tron_requestAccounts`.\nexport const TRON_USER_REJECTION_CODE = 4001;\nexport const WALLET_NAME_IN_WALLET_STANDARD = 'OKX Wallet';\n\nexport const OKX_WALLET_SUPPORTED_CHAINS = [\n LegacyNetworks.ETHEREUM,\n LegacyNetworks.BSC,\n LegacyNetworks.POLYGON,\n LegacyNetworks.FANTOM,\n LegacyNetworks.ARBITRUM,\n LegacyNetworks.OPTIMISM,\n LegacyNetworks.CRONOS,\n LegacyNetworks.BOBA,\n LegacyNetworks.GNOSIS,\n LegacyNetworks.MOONBEAM,\n LegacyNetworks.MOONRIVER,\n LegacyNetworks.HARMONY,\n LegacyNetworks.AVAX_CCHAIN,\n];\n\nexport const metadata: ProviderMetadata = {\n name: 'OKX',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n brave:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n firefox: 'https://addons.mozilla.org/en-US/firefox/addon/okexwallet',\n homepage: 'https://www.okx.com/web3',\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 getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter((blockchainMeta) =>\n OKX_WALLET_SUPPORTED_CHAINS.includes(\n blockchainMeta.name as LegacyNetworks\n )\n ),\n },\n {\n label: 'Solana',\n value: 'Solana',\n id: 'SOLANA',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n solanaBlockchain(allBlockchains),\n },\n {\n label: 'BTC',\n value: 'UTXO',\n id: 'BTC',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (chain): chain is TransferBlockchainMeta =>\n chain.name === Networks.BTC\n ),\n },\n {\n label: 'Ton',\n value: 'Ton',\n id: 'TON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tonBlockchain(allBlockchains),\n },\n {\n label: 'Tron',\n value: 'Tron',\n id: 'TRON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tronBlockchain(allBlockchains),\n },\n {\n label: 'Sui',\n value: 'Sui',\n id: 'SUI',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (chain): chain is SuiBlockchainMeta =>\n chain.type === TransactionType.SUI\n ),\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 SOLANA_NAMESPACE,\n UTXO_NAMESPACE,\n TON_NAMESPACE,\n TRON_NAMESPACE,\n} from '@hub3js/namespaces';\nimport {\n dynamicImportWithRefinedError,\n getNetworkInstance,\n} from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { OKXSolanaSigner } from './signers/solana.js';\nimport { OKXTonSigner } from './signers/ton.js';\nimport { OKXUTXOSigner } from './signers/utxo.js';\nimport { suiWalletInstance } from './utils.js';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = getNetworkInstance(provider, EVM_NAMESPACE);\n const solProvider = getNetworkInstance(provider, SOLANA_NAMESPACE);\n const utxoProvider = getNetworkInstance(provider, UTXO_NAMESPACE);\n const tonProvider = getNetworkInstance(provider, TON_NAMESPACE);\n const tronProvider = getNetworkInstance(provider, TRON_NAMESPACE);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-evm')\n );\n const { DefaultTronSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-tron')\n );\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n signers.registerSigner(TxType.SOLANA, new OKXSolanaSigner(solProvider));\n signers.registerSigner(TxType.TRANSFER, new OKXUTXOSigner(utxoProvider));\n signers.registerSigner(TxType.TON, new OKXTonSigner(tonProvider));\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));\n\n const suiProvider = suiWalletInstance();\n if (suiProvider) {\n const { DefaultSuiSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-sui')\n );\n signers.registerSigner(TxType.SUI, new DefaultSuiSigner(suiProvider));\n }\n\n return signers;\n}\n", "import {\n DefaultSolanaSigner,\n type SolanaExternalProvider,\n} from '@rango-dev/signer-solana';\nimport { SignerError, SignerErrorCode } from 'rango-types';\n\nexport class OKXSolanaSigner extends DefaultSolanaSigner {\n constructor(provider: SolanaExternalProvider) {\n super(provider);\n }\n\n async signMessage(msg: string): Promise<string> {\n try {\n const { signature } = await this.provider.request({\n method: 'signMessage',\n params: {\n message: msg,\n },\n });\n return signature;\n } catch (error) {\n throw new SignerError(SignerErrorCode.SIGN_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n TonConnectWalletResponseError,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { GenericSigner, TonTransaction } from 'rango-types';\n\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\nimport { SignerError, SignerErrorCode, TonChainID } from 'rango-types';\n\nimport { TON_CONNECT_USER_REJECTED_CODE } from '../constants.js';\nimport { nextTonRequestId } from '../namespaces/ton/utils.js';\n\nfunction toSignerError(response: TonConnectWalletResponseError): SignerError {\n const code =\n response.error.code === TON_CONNECT_USER_REJECTED_CODE\n ? SignerErrorCode.REJECTED_BY_USER\n : SignerErrorCode.SEND_TX_ERROR;\n return new SignerError(code, response.error.message, response.error);\n}\n\nexport class OKXTonSigner implements GenericSigner<TonTransaction> {\n private provider: TonProviderApi;\n\n constructor(provider: TonProviderApi) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: TonTransaction): Promise<{ hash: string }> {\n const { validUntil, network, from, messages } = tx;\n\n const { Address, Cell } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n\n const transactionPayload = {\n valid_until: validUntil,\n network: network ?? TonChainID.MAINNET,\n ...(from && { from: Address.parse(from).toRawString() }),\n messages: messages.map(({ stateInit, payload, ...message }) => ({\n ...message,\n ...(stateInit != null && { stateInit }),\n ...(payload != null && { payload }),\n })),\n };\n\n try {\n const response = await this.provider.send({\n method: 'sendTransaction',\n params: [JSON.stringify(transactionPayload)],\n id: nextTonRequestId(),\n });\n\n if ('error' in response) {\n throw toSignerError(response);\n }\n\n const hash = Cell.fromBase64(response.result).hash().toString('hex');\n return { hash };\n } catch (error) {\n if (error instanceof SignerError) {\n throw error;\n }\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n Environments,\n TonAddressItemReply,\n TonConnectEvent,\n TonConnectEventSuccess,\n} from './types.js';\nimport type { CaipAccount } from '@hub3js/std/types';\n\nimport { utils as tonCoreUtils } from '@hub3js/tvm';\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\n\nexport function isTonConnectEventSuccess(\n event: TonConnectEvent\n): event is TonConnectEventSuccess {\n return (\n !!event && event.event === 'connect' && Array.isArray(event.payload?.items)\n );\n}\n\nexport function isTonAddressItemReply(\n item: unknown\n): item is TonAddressItemReply {\n return (\n typeof item === 'object' &&\n item !== null &&\n 'name' in item &&\n item.name === 'ton_addr' &&\n 'address' in item &&\n typeof item.address === 'string'\n );\n}\n\nlet environments: Environments | undefined;\n\nexport function setEnvironments(env?: Environments) {\n environments = env;\n}\n\nexport function getTonConnectManifestUrl(): string {\n const manifestUrl = environments?.tonConnectManifestUrl;\n if (!manifestUrl) {\n throw new Error(\n 'OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.'\n );\n }\n return manifestUrl;\n}\n\nlet tonRequestId = 0;\n\n// TonConnect requires a unique string `id` on every request sent to the bridge.\nexport function nextTonRequestId(): string {\n tonRequestId += 1;\n return tonRequestId.toString();\n}\n\n// Convert a `ConnectEvent`'s raw `<workchain>:<hex>` address to user-friendly CAIP.\nexport async function connectEventToCAIP(\n connectEvent: TonConnectEvent\n): Promise<CaipAccount[]> {\n if (!isTonConnectEventSuccess(connectEvent)) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const addressItem = connectEvent.payload.items.find(isTonAddressItemReply);\n if (!addressItem) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const { Address } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n const userFriendlyAddress = Address.parseRaw(addressItem.address).toString({\n bounceable: false,\n urlSafe: true,\n });\n\n return tonCoreUtils.formatAccountsToCAIP([userFriendlyAddress]);\n}\n", "import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/utxo';\nimport type { GenericSigner, Transfer } from 'rango-types';\n\nimport { Networks } from '@rango-dev/wallets-shared';\nimport { SignerError } from 'rango-types';\n\nexport class OKXUTXOSigner 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 (asset.blockchain !== Networks.BTC) {\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 try {\n // 3. Sign (& auto-finalize)\n const signedPsbtHex = await this.provider.signPsbt(psbtHex, {\n autoFinalized: true,\n toSignInputs,\n });\n\n // 4. Push signed psbt\n const transactionHash = await this.provider.pushPsbt(signedPsbtHex);\n\n return { hash: transactionHash };\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}\n", "import type { TonProviderApi } from './namespaces/ton/types.js';\nimport type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';\nimport type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';\nimport type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';\nimport type { ProviderAPI as SuiProviderApi } from '@hub3js/sui';\nimport type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';\nimport type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport {\n EVM_NAMESPACE,\n SOLANA_NAMESPACE,\n TON_NAMESPACE,\n TRON_NAMESPACE,\n UTXO_NAMESPACE,\n} from '@hub3js/namespaces';\nimport { getInstanceOrThrow as getSuiInstanceOrThrow } from '@hub3js/sui';\n\nimport { WALLET_NAME_IN_WALLET_STANDARD } from './constants.js';\n\nexport function okx(): Provider | null {\n const { okxwallet, okxTonWallet } = window;\n if (!okxwallet && !okxTonWallet) {\n return null;\n }\n const instances: Provider = new Map();\n if (okxwallet) {\n instances.set(EVM_NAMESPACE, okxwallet);\n }\n if (okxwallet.solana) {\n instances.set(SOLANA_NAMESPACE, okxwallet.solana);\n }\n if (okxwallet.bitcoin) {\n instances.set(UTXO_NAMESPACE, okxwallet.bitcoin);\n }\n if (okxTonWallet?.tonconnect) {\n instances.set(TON_NAMESPACE, okxTonWallet.tonconnect);\n }\n if (okxwallet.tronLink) {\n instances.set(TRON_NAMESPACE, okxwallet.tronLink);\n }\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = okx();\n\n if (!instances) {\n throw new Error('OKX Wallet is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmOKX(): EvmProviderApi {\n const instances = okx();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'OKX Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance as EvmProviderApi;\n}\n\nexport function solanaOKX(): SolanaProviderApi {\n const instance = okx();\n const solanaInstance = instance?.get(SOLANA_NAMESPACE);\n\n if (!solanaInstance) {\n throw new Error(\n 'OKX Wallet not injected or Solana not enabled. Please check your wallet.'\n );\n }\n\n return solanaInstance;\n}\nexport function bitcoinOKX(): UtxoProviderApi {\n const instance = okx();\n const bitcoinInstance = instance?.get(UTXO_NAMESPACE);\n\n if (!bitcoinInstance) {\n throw new Error(\n 'OKX Wallet not injected or Utxo not enabled. Please check your wallet.'\n );\n }\n\n return bitcoinInstance;\n}\n\nexport function tonOKX(): TonProviderApi {\n const instance = okx();\n const tonInstance = instance?.get(TON_NAMESPACE);\n\n if (!tonInstance) {\n throw new Error(\n 'OKX Wallet not injected or TON not enabled. Please check your wallet.'\n );\n }\n\n return tonInstance as TonProviderApi;\n}\n\nexport function tronOKX(): TronProviderApi {\n const instance = okx();\n const tronInstance = instance?.get(TRON_NAMESPACE);\n\n if (!tronInstance) {\n throw new Error(\n 'OKX Wallet not injected or Tron not enabled. Please check your wallet.'\n );\n }\n\n return tronInstance;\n}\n\nexport function suiWalletInstance(): SuiProviderApi | null {\n try {\n return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);\n } catch {\n return null;\n }\n}\n\nexport function suiWalletInstanceOrThrow(): SuiProviderApi {\n return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);\n}\nexport async function getBitcoinAccounts(): Promise<OkxBtcAddress> {\n const instance = bitcoinOKX();\n const requestResult = await instance.connect();\n\n if (requestResult.error?.message) {\n throw new Error(requestResult.error.message);\n }\n\n return requestResult;\n}\n\nexport function isOkxTronMessageEvent(\n value: unknown\n): value is OkxTronMessageEvent {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const event = value as { message?: { action?: unknown } };\n return (\n typeof event.message === 'object' &&\n event.message !== null &&\n typeof event.message.action === 'string'\n );\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(evmOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload.length) {\n event.preventDefault();\n }\n })\n .format(async (instance, event) => {\n const chainId = await instance.request({ method: 'eth_chainId' });\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event.filter(Boolean), chainId);\n })\n .build();\nconst connect = builders\n .connect()\n .action(actions.connect(evmOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .before(() => {\n evmOKX().disconnect();\n })\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(evmOKX))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmOKX))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import type { SolanaActions } from '@hub3js/solana';\n\nimport { ActionBuilder, NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/solana';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { solanaOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(solanaOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event ? [event] : []);\n })\n .build();\n\nconst connect = builders\n .connect()\n .action(actions.connect(solanaOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SolanaActions>()\n .before(() => {\n solanaOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst canEagerConnect = new ActionBuilder<SolanaActions, 'canEagerConnect'>(\n 'canEagerConnect'\n)\n .action(actions.canEagerConnect(solanaOKX))\n .build();\n\nconst solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { solana };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { builders, type TonActions } from '@hub3js/tvm';\n\nimport { tonActions } from '../../actions/ton.js';\nimport { tonBuilders } from '../../builders/ton.js';\nimport { WALLET_ID } from '../../constants.js';\nimport { tonOKX } from '../../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tonBuilders\n .changeAccountSubscriber(tonOKX)\n .build();\n\nconst [walletDisconnectSubscriber, walletDisconnectCleanup] = tonBuilders\n .disconnectSubscriber(tonOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tonActions.connect(tonOKX))\n .before(changeAccountSubscriber)\n .before(walletDisconnectSubscriber)\n .or(walletDisconnectCleanup)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TonActions>()\n .before(tonActions.disconnect(tonOKX))\n .after(changeAccountCleanup)\n .after(walletDisconnectCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tonActions.canEagerConnect(tonOKX))\n .build();\n\nconst ton = new NamespaceBuilder<TonActions>('Ton', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { ton };\n", "import type {\n TonConnectEvent,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { Context, FunctionWithContext } from '@hub3js/core';\n\nimport { type TonActions } from '@hub3js/tvm';\n\nimport {\n TON_CONNECT_PROTOCOL_VERSION,\n TON_CONNECT_USER_REJECTED_CODE,\n} from '../constants.js';\nimport {\n connectEventToCAIP,\n getTonConnectManifestUrl,\n isTonConnectEventSuccess,\n nextTonRequestId,\n} from '../namespaces/ton/utils.js';\n\nexport function connect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['connect'], Context> {\n return async () => {\n const instance = getInstance();\n\n /*\n * If the dApp was approved before, `restoreConnection` resolves the current\n * session without prompting the user; otherwise fall back to a fresh\n * connect request.\n */\n let connectEvent: TonConnectEvent | undefined;\n try {\n connectEvent = await instance.restoreConnection();\n } catch {\n // No restorable session; a fresh connect request is made below.\n }\n\n if (!connectEvent || !isTonConnectEventSuccess(connectEvent)) {\n connectEvent = await instance.connect(TON_CONNECT_PROTOCOL_VERSION, {\n manifestUrl: getTonConnectManifestUrl(),\n items: [{ name: 'ton_addr' }],\n });\n }\n\n if (!isTonConnectEventSuccess(connectEvent)) {\n // The bridge reports a user-cancelled prompt as a `connect_error` event.\n if (connectEvent.payload.code === TON_CONNECT_USER_REJECTED_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n `Couldn't connect to OKX TON. code: ${connectEvent.payload.code}, message: ${connectEvent.payload.message}`\n );\n }\n\n const accounts = await connectEventToCAIP(connectEvent);\n if (!accounts.length) {\n throw new Error(\"Couldn't find any TON address!\");\n }\n\n return accounts;\n };\n}\n\nexport function canEagerConnect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['canEagerConnect'], Context> {\n return async () => {\n /*\n * Auto connect may run this before the wallet is injected; it should never\n * throw.\n */\n try {\n const connectEvent = await getInstance().restoreConnection();\n return isTonConnectEventSuccess(connectEvent);\n } catch {\n return false;\n }\n };\n}\n\nexport function disconnect(getInstance: () => TonProviderApi) {\n return async () => {\n /*\n * Revoking the session on the wallet side is best effort; local state\n * cleanup should proceed even if it fails.\n */\n try {\n await getInstance().send({\n method: 'disconnect',\n params: [],\n id: nextTonRequestId(),\n });\n } catch {\n // ignore\n }\n };\n}\n\nexport const tonActions = { connect, canEagerConnect, disconnect };\n", "import type { TonProviderApi } from '../namespaces/ton/types.js';\n\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport { type TonActions, utils } from '@hub3js/tvm';\n\nimport { connectEventToCAIP } from '../namespaces/ton/utils.js';\n\n/*\n * OKX emits its non-standard `accountChanged` event without a documented\n * payload, so the switched address can't be read from the event. Because the\n * bridge is standard TON Connect, `format` re-reads the active account from the\n * instance via `restoreConnection` instead\n */\nexport const changeAccountSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .format(async (instance) => {\n try {\n const connectEvent = await instance.restoreConnection();\n return await connectEventToCAIP(connectEvent);\n } catch {\n // No active session after the switch \u2014 treat as disconnected.\n return utils.formatAccountsToCAIP([]);\n }\n })\n .addEventListener((instance, callback) => {\n instance.on('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('accountChanged', callback);\n });\n\nexport const disconnectSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n event.preventDefault();\n void context.action('disconnect');\n })\n .format(async () => [])\n .addEventListener((instance, callback) => {\n instance.on('disconnect', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('disconnect', callback);\n });\n\nexport const tonBuilders = { changeAccountSubscriber, disconnectSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { type TronActions } 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 { WALLET_ID } from '../constants.js';\nimport { tronOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tronBuilders\n .changeAccountSubscriber(tronOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tronActions.connect)\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tronActions.canEagerConnect)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TronActions>()\n .after(changeAccountCleanup)\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 { utils } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport {\n TRON_OK_REQUEST_CODE,\n TRON_USER_REJECTION_CODE,\n} from '../constants.js';\nimport { tronOKX } from '../utils.js';\n\nconst connect = async () => {\n const instance = tronOKX();\n const accountsResult = await instance.request({\n method: 'tron_requestAccounts',\n });\n\n if (accountsResult?.code && accountsResult.code !== TRON_OK_REQUEST_CODE) {\n if (accountsResult.code === TRON_USER_REJECTION_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n accountsResult.message ?? 'Failed to connect to OKX Wallet Tron.'\n );\n }\n return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);\n};\n\n/*\n * Wrapped in a try-catch in the case of wallet injection delay\n */\nconst canEagerConnect = async () => {\n try {\n const tronInstance = tronOKX();\n return !!tronInstance.ready;\n } catch {\n return false;\n }\n};\nexport const tronActions = { connect, canEagerConnect };\n", "import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n type ProviderAPI,\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { isOkxTronMessageEvent } from '../utils.js';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<\n MessageEvent<unknown>,\n ProviderAPI,\n TronActions\n >()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n const data = event.payload?.data;\n\n if (!isOkxTronMessageEvent(data)) {\n event.preventDefault();\n return;\n }\n\n const { action } = data.message;\n\n if (action === 'disconnect') {\n event.preventDefault();\n context.action('disconnect');\n return;\n }\n\n /*\n * Change account only on `accountsChanged` with a string address (`format`\n * reads it). Everything else \u2014 including `accountsChanged` with address\n * `false` (its disconnect is handled above) \u2014 is ignored.\n */\n if (\n action !== 'accountsChanged' ||\n typeof data.message.data?.address !== 'string'\n ) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n const data = event.data;\n const address =\n isOkxTronMessageEvent(data) && data.message.action === 'accountsChanged'\n ? data.message.data?.address\n : undefined;\n if (typeof address !== 'string') {\n throw new Error('No Tron address received from OKX Wallet.');\n }\n return utils.formatAccountsToCAIP([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 { SuiActions } from '@hub3js/sui';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { actions, builders, hooks } from '@hub3js/sui';\n\nimport { WALLET_ID, WALLET_NAME_IN_WALLET_STANDARD } from '../constants.js';\nimport { suiHooks } from '../hooks/sui.js';\nimport { suiWalletInstanceOrThrow } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber({\n name: WALLET_NAME_IN_WALLET_STANDARD,\n });\n\nconst [disconnectSubscriber, disconnectCleanup] = suiHooks.disconnectSubscriber(\n suiWalletInstanceOrThrow\n);\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(\n actions.canEagerConnect({\n name: WALLET_NAME_IN_WALLET_STANDARD,\n })\n )\n .build();\n\nconst connect = builders\n .connect({\n name: WALLET_NAME_IN_WALLET_STANDARD,\n })\n .before(changeAccountSubscriber)\n .before(disconnectSubscriber)\n .or(changeAccountCleanup)\n .or(disconnectCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SuiActions>()\n .after(changeAccountCleanup)\n .after(disconnectCleanup)\n .build();\n\nconst sui = new NamespaceBuilder<SuiActions>('Sui', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { sui };\n", "import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';\nimport type { ProviderAPI, SuiActions } from '@hub3js/sui';\n\n/*\n * OKX's Sui wallet-standard instance emits a `disconnect` event on its\n * `standard:events` feature when the user disconnects from the wallet UI.\n * Account switches come through `change` (handled by the core change\n * subscriber); disconnect is NOT surfaced there. The `disconnect` event is\n * undocumented in the wallet-standard types, which only declare `change`, hence\n * the cast on `.on`. `.on` returns an unsubscribe function that the cleanup invokes.\n */\nfunction disconnectSubscriber(\n getInstance: () => ProviderAPI\n): [Subscriber<SuiActions>, SubscriberCleanUp<SuiActions>] {\n let unsubscribe: (() => void) | void;\n\n return [\n (context) => {\n const instance = getInstance();\n\n if (!instance) {\n throw new Error(\n 'Trying to subscribe to your Sui wallet, but seems its instance is not available.'\n );\n }\n\n unsubscribe = (\n instance.features['standard:events'].on as (\n event: string,\n listener: (event: unknown) => void\n ) => () => void\n )('disconnect', () => {\n context.action('disconnect');\n });\n },\n (_context, err) => {\n if (typeof unsubscribe === 'function') {\n unsubscribe();\n }\n\n return err;\n },\n ];\n}\n\nexport const suiHooks = { disconnectSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\nimport { builders } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { utxoBuilders } from '../builders/utxo.js';\nimport { WALLET_ID } from '../constants.js';\nimport { bitcoinOKX, getBitcoinAccounts } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = utxoBuilders\n .changeAccountSubscriber(bitcoinOKX)\n .build();\n\nconst canEagerConnect = utxoBuilders.canEagerConnect(bitcoinOKX).build();\n\nconst connect = builders\n .connect()\n .action(async function () {\n const accountsResult = await getBitcoinAccounts();\n\n if (!accountsResult?.address) {\n throw new Error(\"Couldn't find any address!\");\n }\n return utils.formatAccountsToCAIP(\n [accountsResult.address],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<UtxoActions>()\n .before(() => {\n bitcoinOKX().disconnect();\n })\n .after(changeAccountCleanup)\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 { OkxBtcAddress } from '../types.js';\n\nimport { ActionBuilder } from '@hub3js/core';\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n type ProviderAPI,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<OkxBtcAddress, ProviderAPI, UtxoActions>()\n .getInstance(getInstance)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload?.address) {\n event.preventDefault();\n }\n })\n\n .format(async (_, event) => {\n return utils.formatAccountsToCAIP(\n event ? [event.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\nfunction canEagerConnect(getInstance: () => ProviderAPI) {\n return new ActionBuilder<UtxoActions, 'canEagerConnect'>(\n 'canEagerConnect'\n ).action(async () => {\n const instance = getInstance();\n try {\n const accounts = await instance.getAccounts();\n return !!accounts.length;\n } catch {\n return false;\n }\n });\n}\n\nexport const utxoBuilders = { changeAccountSubscriber, canEagerConnect };\n"],
|
|
5
|
+
"mappings": "iFAAA,OAAS,kBAAAA,OAAsB,qBCE/B,OAAS,mBAAAC,OAAuB,eCAhC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,YAAAC,OAAgB,4BACzB,OAEE,oBAAAC,GACA,iBAAAC,GAEA,mBAAAC,GAEA,kBAAAC,OACK,cCTP,OACE,iBAAAC,GACA,oBAAAC,GACA,kBAAAC,GACA,iBAAAC,GACA,kBAAAC,OACK,qBACP,OACE,iCAAAC,EACA,sBAAAC,MACK,4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M,ElBpCT,IAAMY,GAAgBC,EAAA,IACpB,IAAIC,GAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAASC,EAA6B,CACpDC,EAAgBD,CAAY,EAC5B,GAAM,CAAC,CAAEE,CAAQ,EAAIH,EAAQ,MAAM,EAE/BI,EAAY,IACdD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,2BAA4BH,CAAO,EAErD,CAAC,EACA,OAAO,WAAYK,EAAQ,EAC3B,IAAI,SAAUC,EAAM,EACpB,IAAI,MAAOC,EAAG,EACd,IAAI,OAAQC,EAAI,EAChB,IAAI,MAAOC,EAAG,EACd,IAAI,OAAQC,EAAI,EAChB,IAAI,MAAOC,EAAG,EAEd,MAAM,EAnBW,iBDVtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EAAE,QAAQ,QAASC,GAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
+
"names": ["defineVersions", "ProviderBuilder", "LegacyNetworks", "Networks", "solanaBlockchain", "tonBlockchain", "TransactionType", "tronBlockchain", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "UTXO_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "dynamicImportWithRefinedError", "getNetworkInstance", "DefaultSignerFactory", "TxType", "DefaultSolanaSigner", "SignerError", "SignerErrorCode", "OKXSolanaSigner", "DefaultSolanaSigner", "__name", "provider", "msg", "signature", "error", "SignerError", "SignerErrorCode", "dynamicImportWithRefinedError", "SignerError", "SignerErrorCode", "TonChainID", "tonCoreUtils", "dynamicImportWithRefinedError", "isTonConnectEventSuccess", "event", "__name", "isTonAddressItemReply", "item", "environments", "setEnvironments", "env", "getTonConnectManifestUrl", "manifestUrl", "tonRequestId", "nextTonRequestId", "connectEventToCAIP", "connectEvent", "tonCoreUtils", "addressItem", "Address", "dynamicImportWithRefinedError", "userFriendlyAddress", "toSignerError", "response", "code", "TON_CONNECT_USER_REJECTED_CODE", "SignerErrorCode", "SignerError", "__name", "OKXTonSigner", "provider", "tx", "validUntil", "network", "from", "messages", "Address", "Cell", "dynamicImportWithRefinedError", "transactionPayload", "TonChainID", "stateInit", "payload", "message", "nextTonRequestId", "error", "Networks", "SignerError", "OKXUTXOSigner", "__name", "provider", "SignerError", "tx", "asset", "psbt", "Networks", "psbtHex", "toSignInputs", "address", "signingIndexes", "index", "signedPsbtHex", "error", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "getSuiInstanceOrThrow", "okx", "okxwallet", "okxTonWallet", "instances", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "UTXO_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "__name", "getInstanceOrThrow", "evmOKX", "evmInstance", "solanaOKX", "solanaInstance", "bitcoinOKX", "bitcoinInstance", "tonOKX", "tonInstance", "tronOKX", "tronInstance", "suiWalletInstance", "getSuiInstanceOrThrow", "WALLET_NAME_IN_WALLET_STANDARD", "suiWalletInstanceOrThrow", "getBitcoinAccounts", "requestResult", "isOkxTronMessageEvent", "value", "event", "getSigners", "provider", "ethProvider", "getNetworkInstance", "EVM_NAMESPACE", "solProvider", "SOLANA_NAMESPACE", "utxoProvider", "UTXO_NAMESPACE", "tonProvider", "TON_NAMESPACE", "tronProvider", "TRON_NAMESPACE", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "dynamicImportWithRefinedError", "DefaultTronSigner", "TxType", "OKXSolanaSigner", "OKXUTXOSigner", "OKXTonSigner", "suiProvider", "suiWalletInstance", "DefaultSuiSigner", "__name", "WALLET_ID", "TON_CONNECT_PROTOCOL_VERSION", "TON_CONNECT_USER_REJECTED_CODE", "TRON_OK_REQUEST_CODE", "TRON_USER_REJECTION_CODE", "WALLET_NAME_IN_WALLET_STANDARD", "OKX_WALLET_SUPPORTED_CHAINS", "LegacyNetworks", "metadata", "allBlockchains", "blockchainMeta", "solanaBlockchain", "chain", "Networks", "tonBlockchain", "tronBlockchain", "TransactionType", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "actions", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "changeAccountSubscriber", "changeAccountCleanup", "builders", "evmOKX", "event", "instance", "chainId", "utils", "connect", "actions", "standardizeAndThrowError", "disconnect", "canSwitchNetwork", "canEagerConnect", "getChainId", "evm", "NamespaceBuilder", "WALLET_ID", "ActionBuilder", "NamespaceBuilder", "actions", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "changeAccountSubscriber", "changeAccountCleanup", "builders", "solanaOKX", "event", "_", "utils", "connect", "actions", "standardizeAndThrowError", "disconnect", "canEagerConnect", "ActionBuilder", "solana", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "connect", "getInstance", "instance", "connectEvent", "isTonConnectEventSuccess", "TON_CONNECT_PROTOCOL_VERSION", "getTonConnectManifestUrl", "TON_CONNECT_USER_REJECTED_CODE", "accounts", "connectEventToCAIP", "__name", "canEagerConnect", "disconnect", "nextTonRequestId", "tonActions", "ChangeAccountSubscriberBuilder", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "instance", "connectEvent", "connectEventToCAIP", "utils", "callback", "disconnectSubscriber", "event", "context", "tonBuilders", "changeAccountSubscriber", "changeAccountCleanup", "tonBuilders", "tonOKX", "walletDisconnectSubscriber", "walletDisconnectCleanup", "connect", "builders", "tonActions", "standardizeAndThrowError", "disconnect", "canEagerConnect", "ton", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "utils", "connect", "__name", "instance", "tronOKX", "accountsResult", "TRON_OK_REQUEST_CODE", "TRON_USER_REJECTION_CODE", "utils", "canEagerConnect", "tronActions", "ChangeAccountSubscriberBuilder", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "event", "context", "data", "isOkxTronMessageEvent", "action", "_", "address", "utils", "callback", "tronBuilders", "changeAccountSubscriber", "changeAccountCleanup", "tronBuilders", "tronOKX", "connect", "builders", "tronActions", "standardizeAndThrowError", "canEagerConnect", "disconnect", "tron", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "actions", "builders", "hooks", "disconnectSubscriber", "getInstance", "unsubscribe", "context", "instance", "_context", "err", "__name", "suiHooks", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "WALLET_NAME_IN_WALLET_STANDARD", "disconnectSubscriber", "disconnectCleanup", "suiHooks", "suiWalletInstanceOrThrow", "canEagerConnect", "builders", "actions", "connect", "standardizeAndThrowError", "disconnect", "sui", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "CAIP_BITCOIN_CHAIN_ID", "utils", "builders", "ActionBuilder", "ChangeAccountSubscriberBuilder", "CAIP_BITCOIN_CHAIN_ID", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "event", "_", "utils", "CAIP_BITCOIN_CHAIN_ID", "instance", "callback", "canEagerConnect", "ActionBuilder", "utxoBuilders", "changeAccountSubscriber", "changeAccountCleanup", "utxoBuilders", "bitcoinOKX", "canEagerConnect", "connect", "builders", "accountsResult", "getBitcoinAccounts", "utils", "CAIP_BITCOIN_CHAIN_ID", "standardizeAndThrowError", "disconnect", "utxo", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "environments", "setEnvironments", "setState", "okx", "metadata", "solana", "evm", "utxo", "ton", "tron", "sui", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/namespaces/sui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8C9C,QAAA,MAAM,GAAG,qDAIC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/ton.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/ton.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAqCxD,QAAA,MAAM,GAAG,qDAIC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Environments, TonAddressItemReply, TonConnectEvent, TonConnectEventSuccess } from './types.js';
|
|
2
|
-
import type { CaipAccount } from '@
|
|
2
|
+
import type { CaipAccount } from '@hub3js/std/types';
|
|
3
3
|
export declare function isTonConnectEventSuccess(event: TonConnectEvent): event is TonConnectEventSuccess;
|
|
4
4
|
export declare function isTonAddressItemReply(item: unknown): item is TonAddressItemReply;
|
|
5
5
|
export declare function setEnvironments(env?: Environments): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,GACrB,KAAK,IAAI,sBAAsB,CAIjC;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,CAS7B;AAID,wBAAgB,eAAe,CAAC,GAAG,CAAC,EAAE,YAAY,QAEjD;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAQjD;AAKD,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAGD,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,WAAW,EAAE,CAAC,CAmBxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../../src/namespaces/tron.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yCAAyC,CAAC;AA8B3E,QAAA,MAAM,IAAI,sDAIA,CAAC;AAEX,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const buildProvider: () => import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@rango-dev/wallets-core/namespaces/
|
|
1
|
+
declare const buildProvider: () => import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@hub3js/tvm").TonActions> & Record<"tron", import("@rango-dev/wallets-core/namespaces/tron").TronActions> & Record<"sui", import("@hub3js/sui").SuiActions>>;
|
|
2
2
|
export { buildProvider };
|
|
3
3
|
//# sourceMappingURL=provider.d.ts.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,aAAa,uZAmBP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoBjD,wBAA8B,UAAU,CACtC,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC,CA6BxB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TonProviderApi } from './namespaces/ton/types.js';
|
|
2
2
|
import type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';
|
|
3
|
-
import type { EVM_NAMESPACE, SOLANA_NAMESPACE, UTXO_NAMESPACE, TON_NAMESPACE } from '@hub3js/namespaces';
|
|
3
|
+
import type { EVM_NAMESPACE, SOLANA_NAMESPACE, UTXO_NAMESPACE, TON_NAMESPACE, TRON_NAMESPACE } from '@hub3js/namespaces';
|
|
4
4
|
import type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';
|
|
5
|
+
import type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';
|
|
5
6
|
import type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
6
7
|
export type OkxBtcAddress = {
|
|
7
8
|
address: string;
|
|
@@ -13,6 +14,15 @@ export type ProviderObject = {
|
|
|
13
14
|
[SOLANA_NAMESPACE]: SolanaProviderApi;
|
|
14
15
|
[UTXO_NAMESPACE]: UtxoProviderApi;
|
|
15
16
|
[TON_NAMESPACE]: TonProviderApi;
|
|
17
|
+
[TRON_NAMESPACE]: TronProviderApi;
|
|
16
18
|
};
|
|
17
19
|
export type Provider = Map<keyof ProviderObject, ProviderObject[keyof ProviderObject]>;
|
|
20
|
+
export type OkxTronMessageEvent = {
|
|
21
|
+
message: {
|
|
22
|
+
action: string;
|
|
23
|
+
data?: {
|
|
24
|
+
address: string | false;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
18
28
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE9F,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC;IAChC,CAAC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACtC,CAAC,cAAc,CAAC,EAAE,eAAe,CAAC;IAClC,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC;IAChC,CAAC,cAAc,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,GAAG,CACxB,MAAM,cAAc,EACpB,cAAc,CAAC,MAAM,cAAc,CAAC,CACrC,CAAC;AAMF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE;YACL,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;SACzB,CAAC;KACH,CAAC;CACH,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { TonProviderApi } from './namespaces/ton/types.js';
|
|
2
|
-
import type { OkxBtcAddress, Provider } from './types.js';
|
|
2
|
+
import type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';
|
|
3
3
|
import type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';
|
|
4
4
|
import type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';
|
|
5
|
+
import type { ProviderAPI as SuiProviderApi } from '@hub3js/sui';
|
|
6
|
+
import type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';
|
|
5
7
|
import type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
6
8
|
export declare function okx(): Provider | null;
|
|
7
9
|
export declare function getInstanceOrThrow(): Provider;
|
|
@@ -9,5 +11,9 @@ export declare function evmOKX(): EvmProviderApi;
|
|
|
9
11
|
export declare function solanaOKX(): SolanaProviderApi;
|
|
10
12
|
export declare function bitcoinOKX(): UtxoProviderApi;
|
|
11
13
|
export declare function tonOKX(): TonProviderApi;
|
|
14
|
+
export declare function tronOKX(): TronProviderApi;
|
|
15
|
+
export declare function suiWalletInstance(): SuiProviderApi | null;
|
|
16
|
+
export declare function suiWalletInstanceOrThrow(): SuiProviderApi;
|
|
12
17
|
export declare function getBitcoinAccounts(): Promise<OkxBtcAddress>;
|
|
18
|
+
export declare function isOkxTronMessageEvent(value: unknown): value is OkxTronMessageEvent;
|
|
13
19
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAa9F,wBAAgB,GAAG,IAAI,QAAQ,GAAG,IAAI,CAsBrC;AAED,wBAAgB,kBAAkB,IAAI,QAAQ,CAQ7C;AAED,wBAAgB,MAAM,IAAI,cAAc,CAYvC;AAED,wBAAgB,SAAS,IAAI,iBAAiB,CAW7C;AACD,wBAAgB,UAAU,IAAI,eAAe,CAW5C;AAED,wBAAgB,MAAM,IAAI,cAAc,CAWvC;AAED,wBAAgB,OAAO,IAAI,eAAe,CAWzC;AAED,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAMzD;AAED,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD;AACD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,CASjE;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,mBAAmB,CAU9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-okx",
|
|
3
|
-
"version": "0.63.1-next.
|
|
3
|
+
"version": "0.63.1-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -26,8 +26,12 @@
|
|
|
26
26
|
"@hub3js/namespaces": "^0.2.2",
|
|
27
27
|
"@hub3js/solana": "^0.3.0",
|
|
28
28
|
"@hub3js/std": "^0.2.0",
|
|
29
|
+
"@hub3js/sui": "^0.2.3",
|
|
30
|
+
"@hub3js/tvm": "^0.2.3",
|
|
29
31
|
"@rango-dev/signer-evm": "^0.44.1-next.0",
|
|
30
32
|
"@rango-dev/signer-solana": "^0.48.1-next.0",
|
|
33
|
+
"@rango-dev/signer-sui": "^0.10.1-next.0",
|
|
34
|
+
"@rango-dev/signer-tron": "^0.41.1-next.0",
|
|
31
35
|
"@rango-dev/wallets-core": "^0.60.1-next.3",
|
|
32
36
|
"@rango-dev/wallets-shared": "^0.61.1-next.4",
|
|
33
37
|
"@ton/core": "^0.59.0",
|
package/readme.md
CHANGED
|
@@ -39,16 +39,23 @@ Supported networks :
|
|
|
39
39
|
The wallet only supports bitcoin.
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
#### 🚧 Sui
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
### Feature
|
|
45
44
|
|
|
45
|
+
#### ⚠️ Connect and AutoConnect
|
|
46
46
|
|
|
47
|
+
For Tron, connecting on page load — or disconnecting and reconnecting within the app —
|
|
48
|
+
returns the **first account you connected**, not the account you last switched to. The OKX
|
|
49
|
+
extension resets the Tron address in these cases and gives no way to recover the active
|
|
50
|
+
one; it corrects itself only once you switch accounts in the wallet.
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
If you sign a transaction while that wrong account is selected, the OKX wallet rejects it
|
|
53
|
+
with a **"Transaction Unavailable"** error.
|
|
49
54
|
|
|
50
55
|
#### ⚠️ Disconnect
|
|
51
56
|
|
|
57
|
+
Disconnecting from `evm` also disconnects `solana`, `tron`, `utxo` and `sui`. However, only `tron` and `sui` receive the disconnect event message.
|
|
58
|
+
`solana` and `utxo` will still appear as connected namespaces because they do not receive the disconnect event; they only disconnect after a page refresh.
|
|
52
59
|
The disconnect function will not work for this wallet, as it attempts to invoke disconnect on the connect method for private key imported wallets.
|
|
53
60
|
If the user disconnects the dApp from the wallet itself, we won't disconnect ourself. But we will get disconnected after refreshing the page.
|
|
54
61
|
If the user connects the wallet to one account, switches to another account, and then disconnects one of the two from the wallet, the dApp automatically switches to the remaining account that wasn’t disconnected.
|
|
@@ -64,6 +71,13 @@ Here’s the updated **Switch Account** section with a concise mention that conn
|
|
|
64
71
|
**Connection order also affects this behavior** depending on which namespace was connected first, some account updates may not propagate correctly across other namespaces. As a result, previously connected namespaces will not update automatically and require a manual disconnect and reconnect to sync the correct account.
|
|
65
72
|
|
|
66
73
|
Additionally, calling `connect` on a namespace that was already connected does not return the address of the newly selected account. To avoid leaving the user in an inconsistent state, we invoke a full wallet `disconnect` when the user disconnects the wallet from the provider.
|
|
74
|
+
An `evm` account switch might not be detected.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
#### ⚠️ Auto Connect
|
|
79
|
+
|
|
80
|
+
On auto connect in `sui` (e.g. page reload), the wallet reconnects to the account that was **first** connected, not the account the user last switched to. If the user connects one account, switches to another in the wallet, and the dApp later reconnects, the silent reconnect resolves the originally connected account rather than the currently active one. There is no client-side workaround, as the wallet exposes no way to read the active account at reconnect time.
|
|
67
81
|
|
|
68
82
|
|
|
69
83
|
---
|
package/src/actions/ton.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
} from '../namespaces/ton/types.js';
|
|
5
5
|
import type { Context, FunctionWithContext } from '@hub3js/core';
|
|
6
6
|
|
|
7
|
-
import { type TonActions } from '@
|
|
7
|
+
import { type TonActions } from '@hub3js/tvm';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
TON_CONNECT_PROTOCOL_VERSION,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { utils } from '@rango-dev/wallets-core/namespaces/tron';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
TRON_OK_REQUEST_CODE,
|
|
5
|
+
TRON_USER_REJECTION_CODE,
|
|
6
|
+
} from '../constants.js';
|
|
7
|
+
import { tronOKX } from '../utils.js';
|
|
8
|
+
|
|
9
|
+
const connect = async () => {
|
|
10
|
+
const instance = tronOKX();
|
|
11
|
+
const accountsResult = await instance.request({
|
|
12
|
+
method: 'tron_requestAccounts',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (accountsResult?.code && accountsResult.code !== TRON_OK_REQUEST_CODE) {
|
|
16
|
+
if (accountsResult.code === TRON_USER_REJECTION_CODE) {
|
|
17
|
+
throw new Error('User rejected the request.');
|
|
18
|
+
}
|
|
19
|
+
throw new Error(
|
|
20
|
+
accountsResult.message ?? 'Failed to connect to OKX Wallet Tron.'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Wrapped in a try-catch in the case of wallet injection delay
|
|
28
|
+
*/
|
|
29
|
+
const canEagerConnect = async () => {
|
|
30
|
+
try {
|
|
31
|
+
const tronInstance = tronOKX();
|
|
32
|
+
return !!tronInstance.ready;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const tronActions = { connect, canEagerConnect };
|
package/src/builders/ton.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TonProviderApi } from '../namespaces/ton/types.js';
|
|
2
2
|
|
|
3
3
|
import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';
|
|
4
|
-
import { type TonActions, utils } from '@
|
|
4
|
+
import { type TonActions, utils } from '@hub3js/tvm';
|
|
5
5
|
|
|
6
6
|
import { connectEventToCAIP } from '../namespaces/ton/utils.js';
|
|
7
7
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';
|
|
2
|
+
import {
|
|
3
|
+
type ProviderAPI,
|
|
4
|
+
type TronActions,
|
|
5
|
+
utils,
|
|
6
|
+
} from '@rango-dev/wallets-core/namespaces/tron';
|
|
7
|
+
|
|
8
|
+
import { isOkxTronMessageEvent } from '../utils.js';
|
|
9
|
+
|
|
10
|
+
export const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>
|
|
11
|
+
new ChangeAccountSubscriberBuilder<
|
|
12
|
+
MessageEvent<unknown>,
|
|
13
|
+
ProviderAPI,
|
|
14
|
+
TronActions
|
|
15
|
+
>()
|
|
16
|
+
.getInstance(getInstance)
|
|
17
|
+
.onSwitchAccount((event, context) => {
|
|
18
|
+
const data = event.payload?.data;
|
|
19
|
+
|
|
20
|
+
if (!isOkxTronMessageEvent(data)) {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { action } = data.message;
|
|
26
|
+
|
|
27
|
+
if (action === 'disconnect') {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
context.action('disconnect');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* Change account only on `accountsChanged` with a string address (`format`
|
|
35
|
+
* reads it). Everything else — including `accountsChanged` with address
|
|
36
|
+
* `false` (its disconnect is handled above) — is ignored.
|
|
37
|
+
*/
|
|
38
|
+
if (
|
|
39
|
+
action !== 'accountsChanged' ||
|
|
40
|
+
typeof data.message.data?.address !== 'string'
|
|
41
|
+
) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.format(async (_, event) => {
|
|
46
|
+
const data = event.data;
|
|
47
|
+
const address =
|
|
48
|
+
isOkxTronMessageEvent(data) && data.message.action === 'accountsChanged'
|
|
49
|
+
? data.message.data?.address
|
|
50
|
+
: undefined;
|
|
51
|
+
if (typeof address !== 'string') {
|
|
52
|
+
throw new Error('No Tron address received from OKX Wallet.');
|
|
53
|
+
}
|
|
54
|
+
return utils.formatAccountsToCAIP([address]);
|
|
55
|
+
})
|
|
56
|
+
.addEventListener((_, callback) => {
|
|
57
|
+
window.addEventListener('message', callback);
|
|
58
|
+
})
|
|
59
|
+
.removeEventListener((_, callback) => {
|
|
60
|
+
window.removeEventListener('message', callback);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const tronBuilders = { changeAccountSubscriber };
|
package/src/constants.ts
CHANGED
|
@@ -6,7 +6,10 @@ import {
|
|
|
6
6
|
type BlockchainMeta,
|
|
7
7
|
solanaBlockchain,
|
|
8
8
|
tonBlockchain,
|
|
9
|
+
type SuiBlockchainMeta,
|
|
10
|
+
TransactionType,
|
|
9
11
|
type TransferBlockchainMeta,
|
|
12
|
+
tronBlockchain,
|
|
10
13
|
} from 'rango-types';
|
|
11
14
|
|
|
12
15
|
import getSigners from './signer.js';
|
|
@@ -15,6 +18,10 @@ import { getInstanceOrThrow } from './utils.js';
|
|
|
15
18
|
export const WALLET_ID = 'okx';
|
|
16
19
|
export const TON_CONNECT_PROTOCOL_VERSION = 2;
|
|
17
20
|
export const TON_CONNECT_USER_REJECTED_CODE = 300;
|
|
21
|
+
export const TRON_OK_REQUEST_CODE = 200;
|
|
22
|
+
// EIP-1193 user-rejected-request code returned by `tron_requestAccounts`.
|
|
23
|
+
export const TRON_USER_REJECTION_CODE = 4001;
|
|
24
|
+
export const WALLET_NAME_IN_WALLET_STANDARD = 'OKX Wallet';
|
|
18
25
|
|
|
19
26
|
export const OKX_WALLET_SUPPORTED_CHAINS = [
|
|
20
27
|
LegacyNetworks.ETHEREUM,
|
|
@@ -84,6 +91,23 @@ export const metadata: ProviderMetadata = {
|
|
|
84
91
|
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
85
92
|
tonBlockchain(allBlockchains),
|
|
86
93
|
},
|
|
94
|
+
{
|
|
95
|
+
label: 'Tron',
|
|
96
|
+
value: 'Tron',
|
|
97
|
+
id: 'TRON',
|
|
98
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
99
|
+
tronBlockchain(allBlockchains),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: 'Sui',
|
|
103
|
+
value: 'Sui',
|
|
104
|
+
id: 'SUI',
|
|
105
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
106
|
+
allBlockchains.filter(
|
|
107
|
+
(chain): chain is SuiBlockchainMeta =>
|
|
108
|
+
chain.type === TransactionType.SUI
|
|
109
|
+
),
|
|
110
|
+
},
|
|
87
111
|
],
|
|
88
112
|
},
|
|
89
113
|
},
|
package/src/hooks/sui.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';
|
|
2
|
+
import type { ProviderAPI, SuiActions } from '@hub3js/sui';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* OKX's Sui wallet-standard instance emits a `disconnect` event on its
|
|
6
|
+
* `standard:events` feature when the user disconnects from the wallet UI.
|
|
7
|
+
* Account switches come through `change` (handled by the core change
|
|
8
|
+
* subscriber); disconnect is NOT surfaced there. The `disconnect` event is
|
|
9
|
+
* undocumented in the wallet-standard types, which only declare `change`, hence
|
|
10
|
+
* the cast on `.on`. `.on` returns an unsubscribe function that the cleanup invokes.
|
|
11
|
+
*/
|
|
12
|
+
function disconnectSubscriber(
|
|
13
|
+
getInstance: () => ProviderAPI
|
|
14
|
+
): [Subscriber<SuiActions>, SubscriberCleanUp<SuiActions>] {
|
|
15
|
+
let unsubscribe: (() => void) | void;
|
|
16
|
+
|
|
17
|
+
return [
|
|
18
|
+
(context) => {
|
|
19
|
+
const instance = getInstance();
|
|
20
|
+
|
|
21
|
+
if (!instance) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'Trying to subscribe to your Sui wallet, but seems its instance is not available.'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
unsubscribe = (
|
|
28
|
+
instance.features['standard:events'].on as (
|
|
29
|
+
event: string,
|
|
30
|
+
listener: (event: unknown) => void
|
|
31
|
+
) => () => void
|
|
32
|
+
)('disconnect', () => {
|
|
33
|
+
context.action('disconnect');
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
(_context, err) => {
|
|
37
|
+
if (typeof unsubscribe === 'function') {
|
|
38
|
+
unsubscribe();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return err;
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const suiHooks = { disconnectSubscriber };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SuiActions } from '@hub3js/sui';
|
|
2
|
+
|
|
3
|
+
import { NamespaceBuilder } from '@hub3js/core';
|
|
4
|
+
import * as commonBuilders from '@hub3js/std/builders';
|
|
5
|
+
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
6
|
+
import { actions, builders, hooks } from '@hub3js/sui';
|
|
7
|
+
|
|
8
|
+
import { WALLET_ID, WALLET_NAME_IN_WALLET_STANDARD } from '../constants.js';
|
|
9
|
+
import { suiHooks } from '../hooks/sui.js';
|
|
10
|
+
import { suiWalletInstanceOrThrow } from '../utils.js';
|
|
11
|
+
|
|
12
|
+
const [changeAccountSubscriber, changeAccountCleanup] =
|
|
13
|
+
hooks.changeAccountSubscriber({
|
|
14
|
+
name: WALLET_NAME_IN_WALLET_STANDARD,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const [disconnectSubscriber, disconnectCleanup] = suiHooks.disconnectSubscriber(
|
|
18
|
+
suiWalletInstanceOrThrow
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const canEagerConnect = builders
|
|
22
|
+
.canEagerConnect()
|
|
23
|
+
.action(
|
|
24
|
+
actions.canEagerConnect({
|
|
25
|
+
name: WALLET_NAME_IN_WALLET_STANDARD,
|
|
26
|
+
})
|
|
27
|
+
)
|
|
28
|
+
.build();
|
|
29
|
+
|
|
30
|
+
const connect = builders
|
|
31
|
+
.connect({
|
|
32
|
+
name: WALLET_NAME_IN_WALLET_STANDARD,
|
|
33
|
+
})
|
|
34
|
+
.before(changeAccountSubscriber)
|
|
35
|
+
.before(disconnectSubscriber)
|
|
36
|
+
.or(changeAccountCleanup)
|
|
37
|
+
.or(disconnectCleanup)
|
|
38
|
+
.or(standardizeAndThrowError)
|
|
39
|
+
.build();
|
|
40
|
+
|
|
41
|
+
const disconnect = commonBuilders
|
|
42
|
+
.disconnect<SuiActions>()
|
|
43
|
+
.after(changeAccountCleanup)
|
|
44
|
+
.after(disconnectCleanup)
|
|
45
|
+
.build();
|
|
46
|
+
|
|
47
|
+
const sui = new NamespaceBuilder<SuiActions>('Sui', WALLET_ID)
|
|
48
|
+
.action(connect)
|
|
49
|
+
.action(disconnect)
|
|
50
|
+
.action(canEagerConnect)
|
|
51
|
+
.build();
|
|
52
|
+
|
|
53
|
+
export { sui };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { NamespaceBuilder } from '@hub3js/core';
|
|
2
2
|
import * as commonBuilders from '@hub3js/std/builders';
|
|
3
3
|
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
4
|
-
import {
|
|
5
|
-
builders,
|
|
6
|
-
type TonActions,
|
|
7
|
-
} from '@rango-dev/wallets-core/namespaces/ton';
|
|
4
|
+
import { builders, type TonActions } from '@hub3js/tvm';
|
|
8
5
|
|
|
9
6
|
import { tonActions } from '../../actions/ton.js';
|
|
10
7
|
import { tonBuilders } from '../../builders/ton.js';
|
|
@@ -4,9 +4,9 @@ import type {
|
|
|
4
4
|
TonConnectEvent,
|
|
5
5
|
TonConnectEventSuccess,
|
|
6
6
|
} from './types.js';
|
|
7
|
-
import type { CaipAccount } from '@
|
|
7
|
+
import type { CaipAccount } from '@hub3js/std/types';
|
|
8
8
|
|
|
9
|
-
import { utils as tonCoreUtils } from '@
|
|
9
|
+
import { utils as tonCoreUtils } from '@hub3js/tvm';
|
|
10
10
|
import { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';
|
|
11
11
|
|
|
12
12
|
export function isTonConnectEventSuccess(
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NamespaceBuilder } from '@hub3js/core';
|
|
2
|
+
import * as commonBuilders from '@hub3js/std/builders';
|
|
3
|
+
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
4
|
+
import { type TronActions } from '@rango-dev/wallets-core/namespaces/tron';
|
|
5
|
+
import { builders } from '@rango-dev/wallets-core/namespaces/tron';
|
|
6
|
+
|
|
7
|
+
import { tronActions } from '../actions/tron.js';
|
|
8
|
+
import { tronBuilders } from '../builders/tron.js';
|
|
9
|
+
import { WALLET_ID } from '../constants.js';
|
|
10
|
+
import { tronOKX } from '../utils.js';
|
|
11
|
+
|
|
12
|
+
const [changeAccountSubscriber, changeAccountCleanup] = tronBuilders
|
|
13
|
+
.changeAccountSubscriber(tronOKX)
|
|
14
|
+
.build();
|
|
15
|
+
|
|
16
|
+
const connect = builders
|
|
17
|
+
.connect()
|
|
18
|
+
.action(tronActions.connect)
|
|
19
|
+
.before(changeAccountSubscriber)
|
|
20
|
+
.or(changeAccountCleanup)
|
|
21
|
+
.or(standardizeAndThrowError)
|
|
22
|
+
.build();
|
|
23
|
+
|
|
24
|
+
const canEagerConnect = builders
|
|
25
|
+
.canEagerConnect()
|
|
26
|
+
.action(tronActions.canEagerConnect)
|
|
27
|
+
.build();
|
|
28
|
+
|
|
29
|
+
const disconnect = commonBuilders
|
|
30
|
+
.disconnect<TronActions>()
|
|
31
|
+
.after(changeAccountCleanup)
|
|
32
|
+
.build();
|
|
33
|
+
|
|
34
|
+
const tron = new NamespaceBuilder<TronActions>('Tron', WALLET_ID)
|
|
35
|
+
.action(connect)
|
|
36
|
+
.action(disconnect)
|
|
37
|
+
.action(canEagerConnect)
|
|
38
|
+
.build();
|
|
39
|
+
|
|
40
|
+
export { tron };
|
package/src/provider.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { evm } from './namespaces/evm.js';
|
|
|
7
7
|
import { solana } from './namespaces/solana.js';
|
|
8
8
|
import { ton } from './namespaces/ton/ton.js';
|
|
9
9
|
import { setEnvironments } from './namespaces/ton/utils.js';
|
|
10
|
+
import { tron } from './namespaces/tron.js';
|
|
11
|
+
import { sui } from './namespaces/sui.js';
|
|
10
12
|
import { utxo } from './namespaces/utxo.js';
|
|
11
13
|
import { okx as okxInstance } from './utils.js';
|
|
12
14
|
|
|
@@ -26,6 +28,8 @@ const buildProvider = () =>
|
|
|
26
28
|
.add('evm', evm)
|
|
27
29
|
.add('utxo', utxo)
|
|
28
30
|
.add('ton', ton)
|
|
31
|
+
.add('tron', tron)
|
|
32
|
+
.add('sui', sui)
|
|
29
33
|
|
|
30
34
|
.build();
|
|
31
35
|
|
package/src/signer.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SOLANA_NAMESPACE,
|
|
7
7
|
UTXO_NAMESPACE,
|
|
8
8
|
TON_NAMESPACE,
|
|
9
|
+
TRON_NAMESPACE,
|
|
9
10
|
} from '@hub3js/namespaces';
|
|
10
11
|
import {
|
|
11
12
|
dynamicImportWithRefinedError,
|
|
@@ -16,6 +17,7 @@ import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
|
16
17
|
import { OKXSolanaSigner } from './signers/solana.js';
|
|
17
18
|
import { OKXTonSigner } from './signers/ton.js';
|
|
18
19
|
import { OKXUTXOSigner } from './signers/utxo.js';
|
|
20
|
+
import { suiWalletInstance } from './utils.js';
|
|
19
21
|
|
|
20
22
|
export default async function getSigners(
|
|
21
23
|
provider: Provider
|
|
@@ -24,15 +26,28 @@ export default async function getSigners(
|
|
|
24
26
|
const solProvider = getNetworkInstance(provider, SOLANA_NAMESPACE);
|
|
25
27
|
const utxoProvider = getNetworkInstance(provider, UTXO_NAMESPACE);
|
|
26
28
|
const tonProvider = getNetworkInstance(provider, TON_NAMESPACE);
|
|
29
|
+
const tronProvider = getNetworkInstance(provider, TRON_NAMESPACE);
|
|
27
30
|
|
|
28
31
|
const signers = new DefaultSignerFactory();
|
|
29
32
|
const { DefaultEvmSigner } = await dynamicImportWithRefinedError(
|
|
30
33
|
async () => await import('@rango-dev/signer-evm')
|
|
31
34
|
);
|
|
35
|
+
const { DefaultTronSigner } = await dynamicImportWithRefinedError(
|
|
36
|
+
async () => await import('@rango-dev/signer-tron')
|
|
37
|
+
);
|
|
32
38
|
signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));
|
|
33
39
|
signers.registerSigner(TxType.SOLANA, new OKXSolanaSigner(solProvider));
|
|
34
40
|
signers.registerSigner(TxType.TRANSFER, new OKXUTXOSigner(utxoProvider));
|
|
35
41
|
signers.registerSigner(TxType.TON, new OKXTonSigner(tonProvider));
|
|
42
|
+
signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));
|
|
43
|
+
|
|
44
|
+
const suiProvider = suiWalletInstance();
|
|
45
|
+
if (suiProvider) {
|
|
46
|
+
const { DefaultSuiSigner } = await dynamicImportWithRefinedError(
|
|
47
|
+
async () => await import('@rango-dev/signer-sui')
|
|
48
|
+
);
|
|
49
|
+
signers.registerSigner(TxType.SUI, new DefaultSuiSigner(suiProvider));
|
|
50
|
+
}
|
|
36
51
|
|
|
37
52
|
return signers;
|
|
38
53
|
}
|
package/src/types.ts
CHANGED
|
@@ -5,8 +5,10 @@ import type {
|
|
|
5
5
|
SOLANA_NAMESPACE,
|
|
6
6
|
UTXO_NAMESPACE,
|
|
7
7
|
TON_NAMESPACE,
|
|
8
|
+
TRON_NAMESPACE,
|
|
8
9
|
} from '@hub3js/namespaces';
|
|
9
10
|
import type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';
|
|
11
|
+
import type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';
|
|
10
12
|
import type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
11
13
|
|
|
12
14
|
export type OkxBtcAddress = {
|
|
@@ -20,8 +22,22 @@ export type ProviderObject = {
|
|
|
20
22
|
[SOLANA_NAMESPACE]: SolanaProviderApi;
|
|
21
23
|
[UTXO_NAMESPACE]: UtxoProviderApi;
|
|
22
24
|
[TON_NAMESPACE]: TonProviderApi;
|
|
25
|
+
[TRON_NAMESPACE]: TronProviderApi;
|
|
23
26
|
};
|
|
24
27
|
export type Provider = Map<
|
|
25
28
|
keyof ProviderObject,
|
|
26
29
|
ProviderObject[keyof ProviderObject]
|
|
27
30
|
>;
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* On `accountsChanged`, `data.address` is the new base58 address, or `false`
|
|
34
|
+
* when disconnected; on `disconnect`, `data` is absent.
|
|
35
|
+
*/
|
|
36
|
+
export type OkxTronMessageEvent = {
|
|
37
|
+
message: {
|
|
38
|
+
action: string;
|
|
39
|
+
data?: {
|
|
40
|
+
address: string | false;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
package/src/utils.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { TonProviderApi } from './namespaces/ton/types.js';
|
|
2
|
-
import type { OkxBtcAddress, Provider } from './types.js';
|
|
2
|
+
import type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';
|
|
3
3
|
import type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';
|
|
4
4
|
import type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';
|
|
5
|
+
import type { ProviderAPI as SuiProviderApi } from '@hub3js/sui';
|
|
6
|
+
import type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';
|
|
5
7
|
import type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
6
8
|
|
|
7
9
|
import {
|
|
8
10
|
EVM_NAMESPACE,
|
|
9
11
|
SOLANA_NAMESPACE,
|
|
10
|
-
UTXO_NAMESPACE,
|
|
11
12
|
TON_NAMESPACE,
|
|
13
|
+
TRON_NAMESPACE,
|
|
14
|
+
UTXO_NAMESPACE,
|
|
12
15
|
} from '@hub3js/namespaces';
|
|
16
|
+
import { getInstanceOrThrow as getSuiInstanceOrThrow } from '@hub3js/sui';
|
|
17
|
+
|
|
18
|
+
import { WALLET_NAME_IN_WALLET_STANDARD } from './constants.js';
|
|
13
19
|
|
|
14
20
|
export function okx(): Provider | null {
|
|
15
21
|
const { okxwallet, okxTonWallet } = window;
|
|
@@ -29,6 +35,9 @@ export function okx(): Provider | null {
|
|
|
29
35
|
if (okxTonWallet?.tonconnect) {
|
|
30
36
|
instances.set(TON_NAMESPACE, okxTonWallet.tonconnect);
|
|
31
37
|
}
|
|
38
|
+
if (okxwallet.tronLink) {
|
|
39
|
+
instances.set(TRON_NAMESPACE, okxwallet.tronLink);
|
|
40
|
+
}
|
|
32
41
|
return instances;
|
|
33
42
|
}
|
|
34
43
|
|
|
@@ -94,6 +103,30 @@ export function tonOKX(): TonProviderApi {
|
|
|
94
103
|
return tonInstance as TonProviderApi;
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
export function tronOKX(): TronProviderApi {
|
|
107
|
+
const instance = okx();
|
|
108
|
+
const tronInstance = instance?.get(TRON_NAMESPACE);
|
|
109
|
+
|
|
110
|
+
if (!tronInstance) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
'OKX Wallet not injected or Tron not enabled. Please check your wallet.'
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return tronInstance;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function suiWalletInstance(): SuiProviderApi | null {
|
|
120
|
+
try {
|
|
121
|
+
return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);
|
|
122
|
+
} catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function suiWalletInstanceOrThrow(): SuiProviderApi {
|
|
128
|
+
return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);
|
|
129
|
+
}
|
|
97
130
|
export async function getBitcoinAccounts(): Promise<OkxBtcAddress> {
|
|
98
131
|
const instance = bitcoinOKX();
|
|
99
132
|
const requestResult = await instance.connect();
|
|
@@ -104,3 +137,17 @@ export async function getBitcoinAccounts(): Promise<OkxBtcAddress> {
|
|
|
104
137
|
|
|
105
138
|
return requestResult;
|
|
106
139
|
}
|
|
140
|
+
|
|
141
|
+
export function isOkxTronMessageEvent(
|
|
142
|
+
value: unknown
|
|
143
|
+
): value is OkxTronMessageEvent {
|
|
144
|
+
if (typeof value !== 'object' || value === null) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const event = value as { message?: { action?: unknown } };
|
|
148
|
+
return (
|
|
149
|
+
typeof event.message === 'object' &&
|
|
150
|
+
event.message !== null &&
|
|
151
|
+
typeof event.message.action === 'string'
|
|
152
|
+
);
|
|
153
|
+
}
|