@rango-dev/provider-enkrypt 0.65.0 → 0.65.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/hooks/evm.d.ts +7 -0
- package/dist/hooks/evm.d.ts.map +1 -0
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/dist/namespaces/evm.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/constants.ts +3 -0
- package/src/hooks/evm.ts +16 -0
- package/src/namespaces/evm.ts +2 -0
package/CHANGELOG.md
CHANGED
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderMetadata } from '@hub3js/core';
|
|
2
2
|
export declare const WALLET_ID = "enkrypt";
|
|
3
|
+
export declare const ENKRYPT_REJECTION = "User Rejected Request: The user rejected the request.";
|
|
3
4
|
export declare const metadata: ProviderMetadata;
|
|
4
5
|
//# 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;AAOrD,eAAO,MAAM,SAAS,YAAY,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,YAAY,CAAC;AAEnC,eAAO,MAAM,iBAAiB,0DAC2B,CAAC;AAC1D,eAAO,MAAM,QAAQ,EAAE,gBAiCtB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from '@hub3js/core';
|
|
2
|
+
declare function convertRejectionError(_context: Context, error: unknown): unknown;
|
|
3
|
+
export declare const evmHooks: {
|
|
4
|
+
convertRejectionError: typeof convertRejectionError;
|
|
5
|
+
};
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=evm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/hooks/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAOzE;AAED,eAAO,MAAM,QAAQ;;CAA4B,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty;var o=(t,e)=>k(t,"name",{value:e,configurable:!0});import{ProviderBuilder as V}from"@hub3js/core";import{isEvmNamespace as j}from"@hub3js/evm";import{EVM_NAMESPACE as w}from"@hub3js/namespaces";import{DefaultSignerFactory as y,TransactionType as b}from"rango-types";async function m(t){let e=t.get(w),c=new y,{DefaultEvmSigner:v}=await import("@rango-dev/signer-evm");return e&&c.registerSigner(b.EVM,new v(e)),c}o(m,"getSigners");import{EVM_NAMESPACE as p}from"@hub3js/namespaces";function s(){let{enkrypt:t}=window,e=t?.providers?.ethereum;if(!e)return null;let c=new Map;return c.set(p,e),c}o(s,"enkrypt");function d(){let t=s();if(!t)throw new Error("Enkrypt Wallet is not injected. Please check your wallet.");return t}o(d,"getInstanceOrThrow");function r(){let e=s()?.get(p);if(!e)throw new Error("Enkrypt Wallet not injected or EVM not enabled. Please check your wallet.");return e}o(r,"evmEnkrypt");var a="enkrypt",l="User Rejected Request: The user rejected the request.",u={name:"Enkrypt",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/enkrypt/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/enkrypt/kkpllkodjeloidieedojogacfhpaihoh",firefox:"https://addons.mozilla.org/en-US/firefox/addon/enkrypt/",brave:"https://chrome.google.com/webstore/detail/enkrypt/kkpllkodjeloidieedojogacfhpaihoh",edge:"https://microsoftedge.microsoft.com/addons/detail/enkrypt-ethereum-polkad/gfenajajnjjmmdojhdjmnngomkhlnfjl",homepage:"https://www.enkrypt.com/"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",isChainSupported:j}]}},{name:"signers",value:{getSigners:async()=>m(d())}}]};import{NamespaceBuilder as T}from"@hub3js/core";import{actions as n,builders as i,hooks as x}from"@hub3js/evm";import*as g from"@hub3js/std/builders";import{standardizeAndThrowError as A}from"@hub3js/std/operators";import{Hub3Error as P}from"@hub3js/core";function S(t,e){return e===l?new P("PROVIDER_USER_REJECTED_REQUEST",e,{cause:e}):e}o(S,"convertRejectionError");var f={convertRejectionError:S};var[R,E]=x.changeAccountSubscriber(r),C=i.connect().action(n.connect(r)).before(R).or(E).or(f.convertRejectionError).or(A).build(),I=g.disconnect().after(E).build(),M=i.canSwitchNetwork().action(n.canSwitchNetwork()).build(),_=i.canEagerConnect().action(n.canEagerConnect(r)).build(),N=i.getChainId().action(n.getChainId(r)).build(),D=i.getAllowance().action(n.getAllowance(r)).build(),L=i.getTransactionReceipt().action(n.getTransactionReceipt(r)).build(),h=new T("EVM",a).action(C).action(I).action(_).action(M).action(N).action(D).action(L).build();var W=o(()=>new V(a).init(function(t){let[,e]=t.state();s()&&(e("installed",!0),console.debug("[enkrypt] instance detected.",t))}).config("metadata",u).add("evm",h).build(),"buildProvider");export{a as WALLET_ID,W as buildProvider};
|
|
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/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/utils.ts", "../src/namespaces/evm.ts"],
|
|
4
|
-
"sourcesContent": ["import { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { enkrypt } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n if (enkrypt()) {\n setState('installed', true);\n console.debug('[enkrypt] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('evm', evm)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { isEvmNamespace } from '@hub3js/evm';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'enkrypt';\nexport const metadata: ProviderMetadata = {\n name: 'Enkrypt',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/enkrypt/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/enkrypt/kkpllkodjeloidieedojogacfhpaihoh',\n firefox: 'https://addons.mozilla.org/en-US/firefox/addon/enkrypt/',\n brave:\n 'https://chrome.google.com/webstore/detail/enkrypt/kkpllkodjeloidieedojogacfhpaihoh',\n edge: 'https://microsoftedge.microsoft.com/addons/detail/enkrypt-ethereum-polkad/gfenajajnjjmmdojhdjmnngomkhlnfjl',\n\n homepage: 'https://www.enkrypt.com/',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: isEvmNamespace,\n },\n ],\n },\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 { EVM_NAMESPACE } from '@hub3js/namespaces';\nimport { DefaultSignerFactory, TransactionType } from 'rango-types';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = provider.get(EVM_NAMESPACE);\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');\n if (!!ethProvider) {\n signers.registerSigner(\n TransactionType.EVM,\n new DefaultEvmSigner(ethProvider)\n );\n }\n return signers;\n}\n", "import type { EnkryptEvmProvider, Provider } from './types.js';\n\nimport { EVM_NAMESPACE } from '@hub3js/namespaces';\n\nexport function enkrypt(): Provider | null {\n const { enkrypt } = window;\n const ethereum = enkrypt?.providers?.ethereum;\n if (!ethereum) {\n return null;\n }\n const instances: Provider = new Map();\n instances.set(EVM_NAMESPACE, ethereum);\n\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = enkrypt();\n\n if (!instances) {\n throw new Error(\n 'Enkrypt Wallet is not injected. Please check your wallet.'\n );\n }\n\n return instances;\n}\n\nexport function evmEnkrypt(): EnkryptEvmProvider {\n const instances = enkrypt();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'Enkrypt Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance;\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, hooks } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmEnkrypt } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber(evmEnkrypt);\nconst connect = builders\n .connect()\n .action(actions.connect(evmEnkrypt))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmEnkrypt))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmEnkrypt))\n .build();\n\nconst getAllowance = builders\n .getAllowance()\n .action(actions.getAllowance(evmEnkrypt))\n .build();\n\nconst getTransactionReceipt = builders\n .getTransactionReceipt()\n .action(actions.getTransactionReceipt(evmEnkrypt))\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 .action(getAllowance)\n .action(getTransactionReceipt)\n .build();\n\nexport { evm };\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,mBAAAA,MAAuB,eCEhC,OAAS,kBAAAC,MAAsB,cCC/B,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,wBAAAC,EAAsB,mBAAAC,MAAuB,cAEtD,eAAOC,EACLC,EACwB,CACxB,IAAMC,EAAcD,EAAS,IAAIE,CAAa,EACxCC,EAAU,IAAIC,EACd,CAAE,iBAAAC,CAAiB,EAAI,KAAM,QAAO,uBAAuB,EACjE,OAAMJ,GACJE,EAAQ,eACNG,EAAgB,IAChB,IAAID,EAAiBJ,CAAW,CAClC,EAEKE,CACT,CAb8BI,EAAAR,EAAA,cCJ9B,OAAS,iBAAAS,MAAqB,qBAEvB,SAASC,GAA2B,CACzC,GAAM,CAAE,QAAAA,CAAQ,EAAI,OACdC,EAAWD,GAAS,WAAW,SACrC,GAAI,CAACC,EACH,OAAO,KAET,IAAMC,EAAsB,IAAI,IAChC,OAAAA,EAAU,IAAIC,EAAeF,CAAQ,EAE9BC,CACT,CAVgBE,EAAAJ,EAAA,WAYT,SAASK,GAA+B,CAC7C,IAAMH,EAAYF,EAAQ,EAE1B,GAAI,CAACE,EACH,MAAM,IAAI,MACR,2DACF,EAGF,OAAOA,CACT,CAVgBE,EAAAC,EAAA,sBAYT,SAASC,GAAiC,CAG/C,IAAMC,EAFYP,EAAQ,GAEK,IAAIG,CAAa,EAEhD,GAAI,CAACI,EACH,MAAM,IAAI,MACR,2EACF,EAGF,OAAOA,CACT,CAZgBH,EAAAE,EAAA,cFrBT,IAAME,EAAY,
|
|
6
|
-
"names": ["ProviderBuilder", "isEvmNamespace", "EVM_NAMESPACE", "DefaultSignerFactory", "TransactionType", "getSigners", "provider", "ethProvider", "EVM_NAMESPACE", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "TransactionType", "__name", "EVM_NAMESPACE", "enkrypt", "ethereum", "instances", "EVM_NAMESPACE", "__name", "getInstanceOrThrow", "evmEnkrypt", "evmInstance", "WALLET_ID", "metadata", "isEvmNamespace", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "actions", "builders", "hooks", "commonBuilders", "standardizeAndThrowError", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "evmEnkrypt", "connect", "builders", "actions", "standardizeAndThrowError", "disconnect", "canSwitchNetwork", "canEagerConnect", "getChainId", "getAllowance", "getTransactionReceipt", "evm", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "enkrypt", "metadata", "evm"]
|
|
3
|
+
"sources": ["../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/hooks/evm.ts"],
|
|
4
|
+
"sourcesContent": ["import { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { enkrypt } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n if (enkrypt()) {\n setState('installed', true);\n console.debug('[enkrypt] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('evm', evm)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { isEvmNamespace } from '@hub3js/evm';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'enkrypt';\n// Enkrypt rejects with a bare string, not an error object.\nexport const ENKRYPT_REJECTION =\n 'User Rejected Request: The user rejected the request.';\nexport const metadata: ProviderMetadata = {\n name: 'Enkrypt',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/enkrypt/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/enkrypt/kkpllkodjeloidieedojogacfhpaihoh',\n firefox: 'https://addons.mozilla.org/en-US/firefox/addon/enkrypt/',\n brave:\n 'https://chrome.google.com/webstore/detail/enkrypt/kkpllkodjeloidieedojogacfhpaihoh',\n edge: 'https://microsoftedge.microsoft.com/addons/detail/enkrypt-ethereum-polkad/gfenajajnjjmmdojhdjmnngomkhlnfjl',\n\n homepage: 'https://www.enkrypt.com/',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: isEvmNamespace,\n },\n ],\n },\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 { EVM_NAMESPACE } from '@hub3js/namespaces';\nimport { DefaultSignerFactory, TransactionType } from 'rango-types';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = provider.get(EVM_NAMESPACE);\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');\n if (!!ethProvider) {\n signers.registerSigner(\n TransactionType.EVM,\n new DefaultEvmSigner(ethProvider)\n );\n }\n return signers;\n}\n", "import type { EnkryptEvmProvider, Provider } from './types.js';\n\nimport { EVM_NAMESPACE } from '@hub3js/namespaces';\n\nexport function enkrypt(): Provider | null {\n const { enkrypt } = window;\n const ethereum = enkrypt?.providers?.ethereum;\n if (!ethereum) {\n return null;\n }\n const instances: Provider = new Map();\n instances.set(EVM_NAMESPACE, ethereum);\n\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = enkrypt();\n\n if (!instances) {\n throw new Error(\n 'Enkrypt Wallet is not injected. Please check your wallet.'\n );\n }\n\n return instances;\n}\n\nexport function evmEnkrypt(): EnkryptEvmProvider {\n const instances = enkrypt();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'Enkrypt Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance;\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, hooks } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmHooks } from '../hooks/evm.js';\nimport { evmEnkrypt } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber(evmEnkrypt);\nconst connect = builders\n .connect()\n .action(actions.connect(evmEnkrypt))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(evmHooks.convertRejectionError)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmEnkrypt))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmEnkrypt))\n .build();\n\nconst getAllowance = builders\n .getAllowance()\n .action(actions.getAllowance(evmEnkrypt))\n .build();\n\nconst getTransactionReceipt = builders\n .getTransactionReceipt()\n .action(actions.getTransactionReceipt(evmEnkrypt))\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 .action(getAllowance)\n .action(getTransactionReceipt)\n .build();\n\nexport { evm };\n", "import type { Context } from '@hub3js/core';\n\nimport { Hub3Error } from '@hub3js/core';\n\nimport { ENKRYPT_REJECTION } from '../constants.js';\n\nfunction convertRejectionError(_context: Context, error: unknown): unknown {\n if (error === ENKRYPT_REJECTION) {\n return new Hub3Error('PROVIDER_USER_REJECTED_REQUEST', error, {\n cause: error,\n });\n }\n return error;\n}\n\nexport const evmHooks = { convertRejectionError };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["ProviderBuilder", "isEvmNamespace", "EVM_NAMESPACE", "DefaultSignerFactory", "TransactionType", "getSigners", "provider", "ethProvider", "EVM_NAMESPACE", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "TransactionType", "__name", "EVM_NAMESPACE", "enkrypt", "ethereum", "instances", "EVM_NAMESPACE", "__name", "getInstanceOrThrow", "evmEnkrypt", "evmInstance", "WALLET_ID", "ENKRYPT_REJECTION", "metadata", "isEvmNamespace", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "actions", "builders", "hooks", "commonBuilders", "standardizeAndThrowError", "Hub3Error", "convertRejectionError", "_context", "error", "ENKRYPT_REJECTION", "Hub3Error", "__name", "evmHooks", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "evmEnkrypt", "connect", "builders", "actions", "evmHooks", "standardizeAndThrowError", "disconnect", "canSwitchNetwork", "canEagerConnect", "getChainId", "getAllowance", "getTransactionReceipt", "evm", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "enkrypt", "metadata", "evm"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/namespaces/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/namespaces/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoD9C,QAAA,MAAM,GAAG,qDAQC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-enkrypt",
|
|
3
|
-
"version": "0.65.
|
|
3
|
+
"version": "0.65.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rango-dev/signer-evm": "^0.47.
|
|
25
|
+
"@rango-dev/signer-evm": "^0.47.1",
|
|
26
26
|
"rango-types": "^0.6.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@hub3js/core": "^0.
|
|
30
|
-
"@hub3js/evm": "^0.
|
|
31
|
-
"@hub3js/namespaces": "^0.
|
|
32
|
-
"@hub3js/std": "^0.
|
|
29
|
+
"@hub3js/core": "^0.64.0",
|
|
30
|
+
"@hub3js/evm": "^0.8.0",
|
|
31
|
+
"@hub3js/namespaces": "^0.8.0",
|
|
32
|
+
"@hub3js/std": "^0.6.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@hub3js/core": "^0.
|
|
36
|
-
"@hub3js/evm": "^0.
|
|
37
|
-
"@hub3js/namespaces": "^0.
|
|
38
|
-
"@hub3js/std": "^0.
|
|
35
|
+
"@hub3js/core": "^0.64.0",
|
|
36
|
+
"@hub3js/evm": "^0.8.0",
|
|
37
|
+
"@hub3js/namespaces": "^0.8.0",
|
|
38
|
+
"@hub3js/std": "^0.6.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
package/src/constants.ts
CHANGED
|
@@ -6,6 +6,9 @@ import getSigners from './signer.js';
|
|
|
6
6
|
import { getInstanceOrThrow } from './utils.js';
|
|
7
7
|
|
|
8
8
|
export const WALLET_ID = 'enkrypt';
|
|
9
|
+
// Enkrypt rejects with a bare string, not an error object.
|
|
10
|
+
export const ENKRYPT_REJECTION =
|
|
11
|
+
'User Rejected Request: The user rejected the request.';
|
|
9
12
|
export const metadata: ProviderMetadata = {
|
|
10
13
|
name: 'Enkrypt',
|
|
11
14
|
icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/enkrypt/icon.svg',
|
package/src/hooks/evm.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from '@hub3js/core';
|
|
2
|
+
|
|
3
|
+
import { Hub3Error } from '@hub3js/core';
|
|
4
|
+
|
|
5
|
+
import { ENKRYPT_REJECTION } from '../constants.js';
|
|
6
|
+
|
|
7
|
+
function convertRejectionError(_context: Context, error: unknown): unknown {
|
|
8
|
+
if (error === ENKRYPT_REJECTION) {
|
|
9
|
+
return new Hub3Error('PROVIDER_USER_REJECTED_REQUEST', error, {
|
|
10
|
+
cause: error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return error;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const evmHooks = { convertRejectionError };
|
package/src/namespaces/evm.ts
CHANGED
|
@@ -6,6 +6,7 @@ import * as commonBuilders from '@hub3js/std/builders';
|
|
|
6
6
|
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
7
7
|
|
|
8
8
|
import { WALLET_ID } from '../constants.js';
|
|
9
|
+
import { evmHooks } from '../hooks/evm.js';
|
|
9
10
|
import { evmEnkrypt } from '../utils.js';
|
|
10
11
|
|
|
11
12
|
const [changeAccountSubscriber, changeAccountCleanup] =
|
|
@@ -15,6 +16,7 @@ const connect = builders
|
|
|
15
16
|
.action(actions.connect(evmEnkrypt))
|
|
16
17
|
.before(changeAccountSubscriber)
|
|
17
18
|
.or(changeAccountCleanup)
|
|
19
|
+
.or(evmHooks.convertRejectionError)
|
|
18
20
|
.or(standardizeAndThrowError)
|
|
19
21
|
.build();
|
|
20
22
|
|