@rango-dev/provider-tonconnect 0.24.1-next.2 → 0.24.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/constants.d.ts +1 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/mod.d.ts +1 -0
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +3 -3
- package/dist/signer.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/constants.ts +1 -2
- package/src/mod.ts +1 -0
- package/src/signer.ts +4 -3
- package/src/types.ts +2 -4
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ProviderMetadata } from '@hub3js/core';
|
|
2
|
-
|
|
3
|
-
export declare const WALLET_ID = WalletTypes.TON_CONNECT;
|
|
2
|
+
export declare const WALLET_ID = "tonconnect";
|
|
4
3
|
export declare const metadata: ProviderMetadata;
|
|
5
4
|
//# 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;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOrD,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC,eAAO,MAAM,QAAQ,EAAE,gBA4BtB,CAAC"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { Environments } from './types.js';
|
|
2
2
|
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"ton", import("@hub3js/tvm").TonActions>>]];
|
|
3
3
|
export { versions };
|
|
4
|
+
export { WALLET_ID } from './constants.js';
|
|
4
5
|
//# 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,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,QAAA,MAAM,QAAQ,uHAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,QAAA,MAAM,QAAQ,uHAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h=Object.defineProperty;var o=(t,n)=>h(t,"name",{value:n,configurable:!0});var M=(t,n)=>()=>(t&&(n=t(t=0)),n);var
|
|
1
|
+
var h=Object.defineProperty;var o=(t,n)=>h(t,"name",{value:n,configurable:!0});var M=(t,n)=>()=>(t&&(n=t(t=0)),n);var F=(t,n)=>{for(var e in n)h(t,e,{get:n[e],enumerable:!0})};var b={};F(b,{CustomTonSigner:()=>u});import{Address as N,Cell as j}from"@ton/core";import{CHAIN as D}from"@tonconnect/ui";import{SignerError as W}from"rango-types";var u,y=M(()=>{"use strict";u=class{static{o(this,"CustomTonSigner")}provider;constructor(n){this.provider=n}async signMessage(){throw W.UnimplementedError("signMessage")}async signAndSendTx(n){let{blockChain:e,type:s,from:r,messages:c,...m}=n,a=await this.provider.sendTransaction({...m,...r&&{from:N.parse(r).toRawString()},messages:c.map(({stateInit:C,payload:T,...U})=>({...U,...C!=null&&{stateInit:C},...T!=null&&{payload:T}})),network:D.MAINNET});return{hash:j.fromBase64(a.boc).hash().toString("hex")}}}});import{defineVersions as $}from"@hub3js/core/utils";import{ProviderBuilder as Z}from"@hub3js/core";import{isTvmNamespace as O}from"@hub3js/tvm";import{TON_NAMESPACE as z}from"@hub3js/namespaces";import{DefaultSignerFactory as L,TransactionType as R}from"rango-types";async function l(t){let n=t.get(z),e=new L,{CustomTonSigner:s}=await Promise.resolve().then(()=>(y(),b));return n&&e.registerSigner(R.TON,new s(n)),e}o(l,"getSigners");import{TON_NAMESPACE as _}from"@hub3js/namespaces";var d=class{static{o(this,"TonConnectAdapter")}#n;#t;async initialize(n){if(!n)throw new Error("Environments are not set");this.#n=await import("@tonconnect/ui");let{TonConnectUI:e}=this.#n;this.#t=new e(n)}getInstance(){if(!this.#t)throw new Error("TonConnect instance isn't initialized. Please ensure you have provided the TonConnect config.");return this.#t}getModule(){if(!this.#n)throw new Error("Couldn't initialize the TonConnect module");return this.#n}async waitForConnection(){let n=this.getInstance();return new Promise((e,s)=>{let r=n.onStatusChange(a=>{!!a?.account.address&&(m(),e(a.account.address))},a=>{m(),s(a)}),c=n.onModalStateChange(a=>{a.closeReason==="action-cancelled"&&(m(),s(new Error("The action was canceled by the user")))}),m=o(()=>{r(),c()},"unsubscribe")})}};var i=new d;function w(){let t=i.getInstance();return new Map([[_,t]])}o(w,"getInstanceOrThrow");var p="tonconnect",v={name:"TON Connect",icon:"https://raw.githubusercontent.com/rango-exchange/assets/7fb19ed5d5019b4d6a41ce91b39cde64f86af4c6/wallets/tonconnect/icon.svg",extensions:{homepage:"https://docs.ton.org/ecosystem/ton-connect/overview"},properties:[{name:"namespaces",value:{selection:"single",data:[{label:"Ton",value:"Ton",id:"TON",isChainSupported:O}]}},{name:"signers",value:{getSigners:async()=>l(w())}}]};import{NamespaceBuilder as q}from"@hub3js/core";import*as I from"@hub3js/std/builders";import{standardizeAndThrowError as J}from"@hub3js/std/operators";import{builders as A}from"@hub3js/tvm";import{utils as k}from"@hub3js/tvm";function B(t){return async()=>{let n=t(),e=await n.connectionRestored,{toUserFriendlyAddress:s}=i.getModule(),r;if(e&&n.account?.address)r=s(n.account.address);else{await n.openModal();let c=await i.waitForConnection();r=s(c)}return k.formatAccountsToCAIP([r])}}o(B,"connect");function H(t){return async()=>await t().connectionRestored}o(H,"canEagerConnect");var f={connect:B,canEagerConnect:H};function G(t){let n,e;return[(s,r)=>{let c=t();if(!c)throw new Error("Trying to subscribe to your Ton wallet, but seems its instance is not available.");if(n=o(m=>{m||s.action("disconnect")},"eventCallback"),e=c.onStatusChange(n),r instanceof Error)throw r},(s,r)=>(e&&e(),r)]}o(G,"getDisconnectSubscriber");async function V(t){let n=i.getInstance();n.connected&&await n.disconnect()}o(V,"handleProviderDisconnect");var g={getDisconnectSubscriber:G,handleProviderDisconnect:V};var[K,S]=g.getDisconnectSubscriber(i.getInstance.bind(i)),Q=A.connect().action(f.connect(i.getInstance.bind(i))).and(K).or(S).or(J).build(),X=A.canEagerConnect().action(f.canEagerConnect(i.getInstance.bind(i))).build(),Y=I.disconnect().before(g.handleProviderDisconnect).after(S).build(),x=new q("Ton",p).action(Q).action(Y).action(X).build();var E=o(()=>new Z(p).init(function(t,n){let[,e]=t.state();async function s(){try{await i.initialize(n),console.debug("[ton] instance initialized.",t),e("installed",!0)}catch(r){console.warn("[ton] failed to initialize TonConnect:",r)}}o(s,"initializeTon"),s()}).config("metadata",v).add("ton",x).build(),"buildProvider");var Hn=o(()=>$().version("1.0.0",E()).build(),"versions");export{p as WALLET_ID,Hn as versions};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/signers/ton.ts", "../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/utils.ts", "../src/tonConnectAdapter.ts", "../src/namespaces/ton.ts", "../src/actions/ton.ts", "../src/hooks/ton.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TonConnectUI } from '@tonconnect/ui';\nimport type { GenericSigner, TonTransaction } from 'rango-types';\n\nimport { Address, Cell } from '@ton/core';\nimport { CHAIN } from '@tonconnect/ui';\nimport { SignerError } from 'rango-types';\n\nexport class CustomTonSigner implements GenericSigner<TonTransaction> {\n private provider: TonConnectUI;\n\n constructor(provider: TonConnectUI) {\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 { blockChain, type, from, messages, ...rest } = tx;\n const result = await this.provider.sendTransaction({\n ...rest,\n ...(from && { from: Address.parse(from).toRawString() }),\n messages: messages.map(({ stateInit, payload, ...msg }) => ({\n ...msg,\n ...(stateInit != null && { stateInit }),\n ...(payload != null && { payload }),\n })),\n network: CHAIN.MAINNET,\n });\n\n const hash = Cell.fromBase64(result.boc).hash().toString('hex');\n return { hash };\n }\n}\n", "import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nexport type { Environments } from './types.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\n", "import type { Environments } from './types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { ton } from './namespaces/ton.js';\nimport { tonConnect } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments: Environments) {\n const [, setState] = context.state();\n\n async function initializeTon() {\n try {\n await tonConnect.initialize(environments);\n console.debug('[ton] instance initialized.', context);\n setState('installed', true);\n } catch (err) {\n console.warn('[ton] failed to initialize TonConnect:', err);\n }\n }\n void initializeTon();\n })\n .config('metadata', metadata)\n .add('ton', ton)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { isTvmNamespace } from '@hub3js/tvm';\nimport { WalletTypes } from '@rango-dev/wallets-shared';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = WalletTypes.TON_CONNECT;\n\nexport const metadata: ProviderMetadata = {\n name: 'TON Connect',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/7fb19ed5d5019b4d6a41ce91b39cde64f86af4c6/wallets/tonconnect/icon.svg',\n extensions: {\n homepage: 'https://docs.ton.org/ecosystem/ton-connect/overview',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'single',\n data: [\n {\n label: 'Ton',\n value: 'Ton',\n id: 'TON',\n isChainSupported: isTvmNamespace,\n },\n ],\n },\n },\n {\n name: 'signers',\n value: {\n getSigners: async () => getSigners(getInstanceOrThrow()),\n },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport { TON_NAMESPACE } from '@hub3js/namespaces';\nimport { getNetworkInstance } from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const tonProvider = getNetworkInstance(provider, TON_NAMESPACE);\n const signers = new DefaultSignerFactory();\n const { CustomTonSigner } = await import('./signers/ton.js');\n signers.registerSigner(TxType.TON, new CustomTonSigner(tonProvider));\n return signers;\n}\n", "import type { Provider } from './types.js';\n\nimport { TON_NAMESPACE } from '@hub3js/namespaces';\n\nimport { TonConnectAdapter } from './tonConnectAdapter.js';\n\nexport const tonConnect = new TonConnectAdapter();\n\nexport function getInstanceOrThrow(): Provider {\n const instance = tonConnect.getInstance();\n\n const instances = new Map([[TON_NAMESPACE, instance]]);\n return instances as Provider;\n}\n", "import type { Environments } from './types.js';\nimport type * as TonConnectUIModule from '@tonconnect/ui';\n\nexport class TonConnectAdapter {\n #tonModule?: typeof TonConnectUIModule;\n #tonConnectInstance?: TonConnectUIModule.TonConnectUI;\n\n async initialize(env?: Environments) {\n if (!env) {\n throw new Error('Environments are not set');\n }\n\n this.#tonModule = await import('@tonconnect/ui');\n const { TonConnectUI } = this.#tonModule;\n this.#tonConnectInstance = new TonConnectUI(env);\n }\n\n getInstance() {\n if (!this.#tonConnectInstance) {\n throw new Error(\n \"TonConnect instance isn't initialized. Please ensure you have provided the TonConnect config.\"\n );\n }\n return this.#tonConnectInstance;\n }\n\n getModule() {\n if (!this.#tonModule) {\n throw new Error(\"Couldn't initialize the TonConnect module\");\n }\n return this.#tonModule;\n }\n\n async waitForConnection(): Promise<string> {\n const tonConnectUI = this.getInstance();\n return new Promise((resolve, reject) => {\n const unsubscribeStatusChange = tonConnectUI.onStatusChange(\n (state) => {\n const walletConnected = !!state?.account.address;\n\n if (walletConnected) {\n unsubscribe();\n resolve(state.account.address);\n }\n },\n (error) => {\n unsubscribe();\n reject(error);\n }\n );\n\n const unsubscribeModalStateChange = tonConnectUI.onModalStateChange(\n (modalState) => {\n if (modalState.closeReason === 'action-cancelled') {\n unsubscribe();\n reject(new Error('The action was canceled by the user'));\n }\n }\n );\n\n const unsubscribe = () => {\n unsubscribeStatusChange();\n unsubscribeModalStateChange();\n };\n });\n }\n}\n", "import type { TonActions } from '@hub3js/tvm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { builders } from '@hub3js/tvm';\n\nimport { tonActions } from '../actions/ton.js';\nimport { WALLET_ID } from '../constants.js';\nimport { tonHooks } from '../hooks/ton.js';\nimport { tonConnect } from '../utils.js';\n\nconst [disconnectSubscriber, disconnectCleanUp] =\n tonHooks.getDisconnectSubscriber(tonConnect.getInstance.bind(tonConnect));\n\nconst connect = builders\n .connect()\n .action(tonActions.connect(tonConnect.getInstance.bind(tonConnect)))\n .and(disconnectSubscriber)\n .or(disconnectCleanUp)\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tonActions.canEagerConnect(tonConnect.getInstance.bind(tonConnect)))\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TonActions>()\n .before(tonHooks.handleProviderDisconnect)\n .after(disconnectCleanUp)\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 { Context, FunctionWithContext } from '@hub3js/core';\nimport type { TonConnectUI } from '@tonconnect/ui';\n\nimport { type TonActions, utils } from '@hub3js/tvm';\n\nimport { tonConnect } from '../utils.js';\n\nexport function connect(\n getInstance: () => TonConnectUI\n): FunctionWithContext<TonActions['connect'], Context> {\n return async () => {\n const tonInstance = getInstance();\n const connectionRestored = await tonInstance.connectionRestored;\n const { toUserFriendlyAddress } = tonConnect.getModule();\n let userFriendlyAddress: string;\n\n if (connectionRestored && tonInstance.account?.address) {\n userFriendlyAddress = toUserFriendlyAddress(tonInstance.account.address);\n } else {\n await tonInstance.openModal();\n const result = await tonConnect.waitForConnection();\n userFriendlyAddress = toUserFriendlyAddress(result);\n }\n\n return utils.formatAccountsToCAIP([userFriendlyAddress]);\n };\n}\n\nexport function canEagerConnect(\n getInstance: () => TonConnectUI\n): FunctionWithContext<TonActions['canEagerConnect'], Context> {\n return async () => {\n const tonConnectUI = getInstance();\n const connectionRestored = await tonConnectUI.connectionRestored;\n return connectionRestored;\n };\n}\n\nexport const tonActions = { connect, canEagerConnect };\n", "import type {\n AnyFunction,\n Context,\n Subscriber,\n SubscriberCleanUp,\n} from '@hub3js/core';\nimport type { TonActions } from '@hub3js/tvm';\nimport type {\n ConnectedWallet,\n ITonConnect,\n TonConnectUI,\n} from '@tonconnect/ui';\n\nimport { tonConnect } from '../utils.js';\n\nfunction getDisconnectSubscriber(\n instance: () => TonConnectUI\n): [Subscriber<TonActions>, SubscriberCleanUp<TonActions>] {\n let eventCallback: AnyFunction;\n let unsubscribe: ReturnType<ITonConnect['onStatusChange']>;\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const tonInstance = instance();\n\n if (!tonInstance) {\n throw new Error(\n 'Trying to subscribe to your Ton wallet, but seems its instance is not available.'\n );\n }\n\n eventCallback = (wallet: null | ConnectedWallet) => {\n if (!wallet) {\n context.action('disconnect');\n }\n };\n\n unsubscribe = tonInstance.onStatusChange(eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_, err) => {\n if (unsubscribe) {\n unsubscribe();\n }\n\n return err;\n },\n ];\n}\n\nexport async function handleProviderDisconnect(_: Context) {\n const tonInstance = tonConnect.getInstance();\n if (tonInstance.connected) {\n await tonInstance.disconnect();\n }\n}\n\nexport const tonHooks = { getDisconnectSubscriber, handleProviderDisconnect };\n"],
|
|
5
|
-
"mappings": "gLAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAGA,OAAS,WAAAC,EAAS,QAAAC,MAAY,YAC9B,OAAS,SAAAC,MAAa,iBACtB,OAAS,eAAAC,MAAmB,cAL5B,IAOaJ,EAPbK,EAAAC,EAAA,kBAOaN,EAAN,KAA+D,CAPtE,MAOsE,CAAAO,EAAA,wBAC5D,SAER,YAAYC,EAAwB,CAClC,KAAK,SAAWA,CAClB,CAEA,MAAM,aAA+B,CACnC,MAAMJ,EAAY,mBAAmB,aAAa,CACpD,CAEA,MAAM,cAAcK,EAA+C,CACjE,GAAM,CAAE,WAAAC,EAAY,KAAAC,EAAM,KAAAC,EAAM,SAAAC,EAAU,GAAGC,CAAK,EAAIL,EAChDM,EAAS,MAAM,KAAK,SAAS,gBAAgB,CACjD,GAAGD,EACH,GAAIF,GAAQ,CAAE,KAAMX,EAAQ,MAAMW,CAAI,EAAE,YAAY,CAAE,EACtD,SAAUC,EAAS,IAAI,CAAC,CAAE,UAAAG,EAAW,QAAAC,EAAS,GAAGC,CAAI,KAAO,CAC1D,GAAGA,EACH,GAAIF,GAAa,MAAQ,CAAE,UAAAA,CAAU,EACrC,GAAIC,GAAW,MAAQ,CAAE,QAAAA,CAAQ,CACnC,EAAE,EACF,QAASd,EAAM,OACjB,CAAC,EAGD,MAAO,CAAE,KADID,EAAK,WAAWa,EAAO,GAAG,EAAE,KAAK,EAAE,SAAS,KAAK,CAChD,CAChB,CACF,IClCA,OAAS,kBAAAI,
|
|
6
|
-
"names": ["ton_exports", "__export", "CustomTonSigner", "Address", "Cell", "CHAIN", "SignerError", "init_ton", "__esmMin", "__name", "provider", "tx", "blockChain", "type", "from", "messages", "rest", "result", "stateInit", "payload", "msg", "defineVersions", "ProviderBuilder", "isTvmNamespace", "
|
|
4
|
+
"sourcesContent": ["import type { TonConnectUI } from '@tonconnect/ui';\nimport type { GenericSigner, TonTransaction } from 'rango-types';\n\nimport { Address, Cell } from '@ton/core';\nimport { CHAIN } from '@tonconnect/ui';\nimport { SignerError } from 'rango-types';\n\nexport class CustomTonSigner implements GenericSigner<TonTransaction> {\n private provider: TonConnectUI;\n\n constructor(provider: TonConnectUI) {\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 { blockChain, type, from, messages, ...rest } = tx;\n const result = await this.provider.sendTransaction({\n ...rest,\n ...(from && { from: Address.parse(from).toRawString() }),\n messages: messages.map(({ stateInit, payload, ...msg }) => ({\n ...msg,\n ...(stateInit != null && { stateInit }),\n ...(payload != null && { payload }),\n })),\n network: CHAIN.MAINNET,\n });\n\n const hash = Cell.fromBase64(result.boc).hash().toString('hex');\n return { hash };\n }\n}\n", "import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nexport type { Environments } from './types.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\nexport { WALLET_ID } from './constants.js';\n", "import type { Environments } from './types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { ton } from './namespaces/ton.js';\nimport { tonConnect } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments: Environments) {\n const [, setState] = context.state();\n\n async function initializeTon() {\n try {\n await tonConnect.initialize(environments);\n console.debug('[ton] instance initialized.', context);\n setState('installed', true);\n } catch (err) {\n console.warn('[ton] failed to initialize TonConnect:', err);\n }\n }\n void initializeTon();\n })\n .config('metadata', metadata)\n .add('ton', ton)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { isTvmNamespace } from '@hub3js/tvm';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'tonconnect';\n\nexport const metadata: ProviderMetadata = {\n name: 'TON Connect',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/7fb19ed5d5019b4d6a41ce91b39cde64f86af4c6/wallets/tonconnect/icon.svg',\n extensions: {\n homepage: 'https://docs.ton.org/ecosystem/ton-connect/overview',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'single',\n data: [\n {\n label: 'Ton',\n value: 'Ton',\n id: 'TON',\n isChainSupported: isTvmNamespace,\n },\n ],\n },\n },\n {\n name: 'signers',\n value: {\n getSigners: async () => getSigners(getInstanceOrThrow()),\n },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport { TON_NAMESPACE } from '@hub3js/namespaces';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const tonProvider = provider.get(TON_NAMESPACE);\n const signers = new DefaultSignerFactory();\n const { CustomTonSigner } = await import('./signers/ton.js');\n if (!!tonProvider) {\n signers.registerSigner(TxType.TON, new CustomTonSigner(tonProvider));\n }\n return signers;\n}\n", "import type { Provider } from './types.js';\n\nimport { TON_NAMESPACE } from '@hub3js/namespaces';\n\nimport { TonConnectAdapter } from './tonConnectAdapter.js';\n\nexport const tonConnect = new TonConnectAdapter();\n\nexport function getInstanceOrThrow(): Provider {\n const instance = tonConnect.getInstance();\n\n const instances = new Map([[TON_NAMESPACE, instance]]);\n return instances as Provider;\n}\n", "import type { Environments } from './types.js';\nimport type * as TonConnectUIModule from '@tonconnect/ui';\n\nexport class TonConnectAdapter {\n #tonModule?: typeof TonConnectUIModule;\n #tonConnectInstance?: TonConnectUIModule.TonConnectUI;\n\n async initialize(env?: Environments) {\n if (!env) {\n throw new Error('Environments are not set');\n }\n\n this.#tonModule = await import('@tonconnect/ui');\n const { TonConnectUI } = this.#tonModule;\n this.#tonConnectInstance = new TonConnectUI(env);\n }\n\n getInstance() {\n if (!this.#tonConnectInstance) {\n throw new Error(\n \"TonConnect instance isn't initialized. Please ensure you have provided the TonConnect config.\"\n );\n }\n return this.#tonConnectInstance;\n }\n\n getModule() {\n if (!this.#tonModule) {\n throw new Error(\"Couldn't initialize the TonConnect module\");\n }\n return this.#tonModule;\n }\n\n async waitForConnection(): Promise<string> {\n const tonConnectUI = this.getInstance();\n return new Promise((resolve, reject) => {\n const unsubscribeStatusChange = tonConnectUI.onStatusChange(\n (state) => {\n const walletConnected = !!state?.account.address;\n\n if (walletConnected) {\n unsubscribe();\n resolve(state.account.address);\n }\n },\n (error) => {\n unsubscribe();\n reject(error);\n }\n );\n\n const unsubscribeModalStateChange = tonConnectUI.onModalStateChange(\n (modalState) => {\n if (modalState.closeReason === 'action-cancelled') {\n unsubscribe();\n reject(new Error('The action was canceled by the user'));\n }\n }\n );\n\n const unsubscribe = () => {\n unsubscribeStatusChange();\n unsubscribeModalStateChange();\n };\n });\n }\n}\n", "import type { TonActions } from '@hub3js/tvm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { builders } from '@hub3js/tvm';\n\nimport { tonActions } from '../actions/ton.js';\nimport { WALLET_ID } from '../constants.js';\nimport { tonHooks } from '../hooks/ton.js';\nimport { tonConnect } from '../utils.js';\n\nconst [disconnectSubscriber, disconnectCleanUp] =\n tonHooks.getDisconnectSubscriber(tonConnect.getInstance.bind(tonConnect));\n\nconst connect = builders\n .connect()\n .action(tonActions.connect(tonConnect.getInstance.bind(tonConnect)))\n .and(disconnectSubscriber)\n .or(disconnectCleanUp)\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tonActions.canEagerConnect(tonConnect.getInstance.bind(tonConnect)))\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TonActions>()\n .before(tonHooks.handleProviderDisconnect)\n .after(disconnectCleanUp)\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 { Context, FunctionWithContext } from '@hub3js/core';\nimport type { TonConnectUI } from '@tonconnect/ui';\n\nimport { type TonActions, utils } from '@hub3js/tvm';\n\nimport { tonConnect } from '../utils.js';\n\nexport function connect(\n getInstance: () => TonConnectUI\n): FunctionWithContext<TonActions['connect'], Context> {\n return async () => {\n const tonInstance = getInstance();\n const connectionRestored = await tonInstance.connectionRestored;\n const { toUserFriendlyAddress } = tonConnect.getModule();\n let userFriendlyAddress: string;\n\n if (connectionRestored && tonInstance.account?.address) {\n userFriendlyAddress = toUserFriendlyAddress(tonInstance.account.address);\n } else {\n await tonInstance.openModal();\n const result = await tonConnect.waitForConnection();\n userFriendlyAddress = toUserFriendlyAddress(result);\n }\n\n return utils.formatAccountsToCAIP([userFriendlyAddress]);\n };\n}\n\nexport function canEagerConnect(\n getInstance: () => TonConnectUI\n): FunctionWithContext<TonActions['canEagerConnect'], Context> {\n return async () => {\n const tonConnectUI = getInstance();\n const connectionRestored = await tonConnectUI.connectionRestored;\n return connectionRestored;\n };\n}\n\nexport const tonActions = { connect, canEagerConnect };\n", "import type {\n AnyFunction,\n Context,\n Subscriber,\n SubscriberCleanUp,\n} from '@hub3js/core';\nimport type { TonActions } from '@hub3js/tvm';\nimport type {\n ConnectedWallet,\n ITonConnect,\n TonConnectUI,\n} from '@tonconnect/ui';\n\nimport { tonConnect } from '../utils.js';\n\nfunction getDisconnectSubscriber(\n instance: () => TonConnectUI\n): [Subscriber<TonActions>, SubscriberCleanUp<TonActions>] {\n let eventCallback: AnyFunction;\n let unsubscribe: ReturnType<ITonConnect['onStatusChange']>;\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const tonInstance = instance();\n\n if (!tonInstance) {\n throw new Error(\n 'Trying to subscribe to your Ton wallet, but seems its instance is not available.'\n );\n }\n\n eventCallback = (wallet: null | ConnectedWallet) => {\n if (!wallet) {\n context.action('disconnect');\n }\n };\n\n unsubscribe = tonInstance.onStatusChange(eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_, err) => {\n if (unsubscribe) {\n unsubscribe();\n }\n\n return err;\n },\n ];\n}\n\nexport async function handleProviderDisconnect(_: Context) {\n const tonInstance = tonConnect.getInstance();\n if (tonInstance.connected) {\n await tonInstance.disconnect();\n }\n}\n\nexport const tonHooks = { getDisconnectSubscriber, handleProviderDisconnect };\n"],
|
|
5
|
+
"mappings": "gLAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAGA,OAAS,WAAAC,EAAS,QAAAC,MAAY,YAC9B,OAAS,SAAAC,MAAa,iBACtB,OAAS,eAAAC,MAAmB,cAL5B,IAOaJ,EAPbK,EAAAC,EAAA,kBAOaN,EAAN,KAA+D,CAPtE,MAOsE,CAAAO,EAAA,wBAC5D,SAER,YAAYC,EAAwB,CAClC,KAAK,SAAWA,CAClB,CAEA,MAAM,aAA+B,CACnC,MAAMJ,EAAY,mBAAmB,aAAa,CACpD,CAEA,MAAM,cAAcK,EAA+C,CACjE,GAAM,CAAE,WAAAC,EAAY,KAAAC,EAAM,KAAAC,EAAM,SAAAC,EAAU,GAAGC,CAAK,EAAIL,EAChD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AAQ,EACR,OAAOC,EAAW,QAAQH,EAAW,YAAY,KAAKA,CAAU,CAAC,CAAC,EAClE,IAAIH,CAAoB,EACxB,GAAGC,CAAiB,EACpB,GAAGM,CAAwB,EAC3B,MAAM,EAEHC,EAAkBH,EACrB,gBAAgB,EAChB,OAAOC,EAAW,gBAAgBH,EAAW,YAAY,KAAKA,CAAU,CAAC,CAAC,EAC1E,MAAM,EAEHM,EACH,aAAuB,EACvB,OAAOP,EAAS,wBAAwB,EACxC,MAAMD,CAAiB,EACvB,MAAM,EAEHS,EAAM,IAAIC,EAA6B,MAAOC,CAAS,EAC1D,OAAOR,CAAO,EACd,OAAOK,CAAU,EACjB,OAAOD,CAAe,EACtB,MAAM,EL9BT,IAAMK,EAAgBC,EAAA,IACpB,IAAIC,EAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAASC,EAA4B,CACnD,GAAM,CAAC,CAAEC,CAAQ,EAAIF,EAAQ,MAAM,EAEnC,eAAeG,GAAgB,CAC7B,GAAI,CACF,MAAMC,EAAW,WAAWH,CAAY,EACxC,QAAQ,MAAM,8BAA+BD,CAAO,EACpDE,EAAS,YAAa,EAAI,CAC5B,OAASG,EAAK,CACZ,QAAQ,KAAK,yCAA0CA,CAAG,CAC5D,CACF,CAReR,EAAAM,EAAA,iBASVA,EAAc,CACrB,CAAC,EACA,OAAO,WAAYG,CAAQ,EAC3B,IAAI,MAAOC,CAAG,EACd,MAAM,EAlBW,iBDFtB,IAAMC,GAAWC,EAAA,IACfC,EAAe,EAAE,QAAQ,QAASC,EAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
+
"names": ["ton_exports", "__export", "CustomTonSigner", "Address", "Cell", "CHAIN", "SignerError", "init_ton", "__esmMin", "__name", "provider", "tx", "blockChain", "type", "from", "messages", "rest", "result", "stateInit", "payload", "msg", "defineVersions", "ProviderBuilder", "isTvmNamespace", "TON_NAMESPACE", "DefaultSignerFactory", "TxType", "getSigners", "provider", "tonProvider", "TON_NAMESPACE", "signers", "DefaultSignerFactory", "CustomTonSigner", "TxType", "__name", "TON_NAMESPACE", "TonConnectAdapter", "__name", "#tonModule", "#tonConnectInstance", "env", "TonConnectUI", "tonConnectUI", "resolve", "reject", "unsubscribeStatusChange", "state", "unsubscribe", "error", "unsubscribeModalStateChange", "modalState", "tonConnect", "TonConnectAdapter", "getInstanceOrThrow", "instance", "TON_NAMESPACE", "__name", "WALLET_ID", "metadata", "isTvmNamespace", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "utils", "connect", "getInstance", "tonInstance", "connectionRestored", "toUserFriendlyAddress", "tonConnect", "userFriendlyAddress", "result", "utils", "__name", "canEagerConnect", "tonActions", "getDisconnectSubscriber", "instance", "eventCallback", "unsubscribe", "context", "err", "tonInstance", "__name", "wallet", "_", "handleProviderDisconnect", "tonConnect", "tonHooks", "disconnectSubscriber", "disconnectCleanUp", "tonHooks", "tonConnect", "connect", "builders", "tonActions", "standardizeAndThrowError", "canEagerConnect", "disconnect", "ton", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "environments", "setState", "initializeTon", "tonConnect", "err", "metadata", "ton", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
7
|
}
|
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;AAKjD,wBAA8B,UAAU,CACtC,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC,CAQxB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { TON_NAMESPACE } from '@hub3js/namespaces';
|
|
2
|
+
import type { InstanceMap } from '@hub3js/std/types';
|
|
2
3
|
import type { TonConnectUI, TonConnectUiOptionsWithManifest } from '@tonconnect/ui';
|
|
3
4
|
export type Environments = TonConnectUiOptionsWithManifest;
|
|
4
5
|
type ProviderObject = {
|
|
5
6
|
[TON_NAMESPACE]: TonConnectUI;
|
|
6
7
|
};
|
|
7
|
-
export type Provider =
|
|
8
|
+
export type Provider = InstanceMap<ProviderObject>;
|
|
8
9
|
export {};
|
|
9
10
|
//# 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,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,+BAA+B,EAChC,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAE3D,KAAK,cAAc,GAAG;IACpB,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,+BAA+B,EAChC,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAE3D,KAAK,cAAc,GAAG;IACpB,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-tonconnect",
|
|
3
|
-
"version": "0.24.1-next.
|
|
3
|
+
"version": "0.24.1-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@hub3js/core": "^0.
|
|
25
|
-
"@hub3js/namespaces": "^0.
|
|
26
|
-
"@hub3js/std": "^0.
|
|
27
|
-
"@hub3js/tvm": "^0.
|
|
28
|
-
"@rango-dev/wallets-shared": "^0.62.1-next.2",
|
|
24
|
+
"@hub3js/core": "^0.62.0",
|
|
25
|
+
"@hub3js/namespaces": "^0.4.0",
|
|
26
|
+
"@hub3js/std": "^0.4.0",
|
|
27
|
+
"@hub3js/tvm": "^0.4.0",
|
|
29
28
|
"@ton/core": "^0.59.0",
|
|
30
29
|
"@ton/crypto": "^3.3.0",
|
|
31
30
|
"@tonconnect/ui": "^2.0.9",
|
|
@@ -34,4 +33,4 @@
|
|
|
34
33
|
"publishConfig": {
|
|
35
34
|
"access": "public"
|
|
36
35
|
}
|
|
37
|
-
}
|
|
36
|
+
}
|
package/src/constants.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { ProviderMetadata } from '@hub3js/core';
|
|
2
2
|
|
|
3
3
|
import { isTvmNamespace } from '@hub3js/tvm';
|
|
4
|
-
import { WalletTypes } from '@rango-dev/wallets-shared';
|
|
5
4
|
|
|
6
5
|
import getSigners from './signer.js';
|
|
7
6
|
import { getInstanceOrThrow } from './utils.js';
|
|
8
7
|
|
|
9
|
-
export const WALLET_ID =
|
|
8
|
+
export const WALLET_ID = 'tonconnect';
|
|
10
9
|
|
|
11
10
|
export const metadata: ProviderMetadata = {
|
|
12
11
|
name: 'TON Connect',
|
package/src/mod.ts
CHANGED
package/src/signer.ts
CHANGED
|
@@ -2,15 +2,16 @@ import type { Provider } from './types.js';
|
|
|
2
2
|
import type { SignerFactory } from 'rango-types';
|
|
3
3
|
|
|
4
4
|
import { TON_NAMESPACE } from '@hub3js/namespaces';
|
|
5
|
-
import { getNetworkInstance } from '@rango-dev/wallets-shared';
|
|
6
5
|
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
7
6
|
|
|
8
7
|
export default async function getSigners(
|
|
9
8
|
provider: Provider
|
|
10
9
|
): Promise<SignerFactory> {
|
|
11
|
-
const tonProvider =
|
|
10
|
+
const tonProvider = provider.get(TON_NAMESPACE);
|
|
12
11
|
const signers = new DefaultSignerFactory();
|
|
13
12
|
const { CustomTonSigner } = await import('./signers/ton.js');
|
|
14
|
-
|
|
13
|
+
if (!!tonProvider) {
|
|
14
|
+
signers.registerSigner(TxType.TON, new CustomTonSigner(tonProvider));
|
|
15
|
+
}
|
|
15
16
|
return signers;
|
|
16
17
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TON_NAMESPACE } from '@hub3js/namespaces';
|
|
2
|
+
import type { InstanceMap } from '@hub3js/std/types';
|
|
2
3
|
import type {
|
|
3
4
|
TonConnectUI,
|
|
4
5
|
TonConnectUiOptionsWithManifest,
|
|
@@ -10,7 +11,4 @@ type ProviderObject = {
|
|
|
10
11
|
[TON_NAMESPACE]: TonConnectUI;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
export type Provider =
|
|
14
|
-
keyof ProviderObject,
|
|
15
|
-
ProviderObject[keyof ProviderObject]
|
|
16
|
-
>;
|
|
14
|
+
export type Provider = InstanceMap<ProviderObject>;
|