@rango-dev/provider-trezor 0.4.2-next.6 → 0.5.1-next.0

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 CHANGED
@@ -1,3 +1,18 @@
1
+ # [0.5.0](https://github.com/rango-exchange/rango-client/compare/provider-trezor@0.4.1...provider-trezor@0.5.0) (2024-10-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump sdk and fix type issues ([d442208](https://github.com/rango-exchange/rango-client/commit/d4422083bf5dd27d5f509ce1db7f9560d05428c8))
7
+
8
+
9
+ ### Performance Improvements
10
+
11
+ * enable code splitting in build process ([fe5a41e](https://github.com/rango-exchange/rango-client/commit/fe5a41e0e297298de11cd74ca5825544742aa03a))
12
+ * lazy load signer packages ([7b88f18](https://github.com/rango-exchange/rango-client/commit/7b88f1834f7b29b4b81ab6c81a07bb88e8ccf55c))
13
+
14
+
15
+
1
16
  ## [0.4.1](https://github.com/rango-exchange/rango-client/compare/provider-trezor@0.4.0...provider-trezor@0.4.1) (2024-09-16)
2
17
 
3
18
 
@@ -0,0 +1,2 @@
1
+ import{a as p,c as u,d as P,e as h,h as e}from"./chunk-VKZ2HTGF.js";import{cleanEvmError as G}from"@rango-dev/signer-evm";import{DEFAULT_ETHEREUM_RPC_URL as z}from"@rango-dev/wallets-shared";import{JsonRpcProvider as S,Transaction as R}from"ethers";import"rango-types";function b(s){return s?.shortMessage?new Error(s.shortMessage,{cause:s}):G(s)}p(b,"getTrezorErrorMessage");var E=class{static{p(this,"EthereumSigner")}async signMessage(r){let o=await h(),{success:n,payload:t}=await o.ethereumSignMessage({message:r,path:u()});if(!n)throw new Error(t.error);return t.signature}async signAndSendTx(r,o,n){try{let t=await h(),{gasPrice:d,maxFeePerGas:i,maxPriorityFeePerGas:c}=r,a=i&&c;if(a&&!i)throw new Error("Missing maxFeePerGas");if(a&&!c)throw new Error("Missing maxPriorityFeePerGas");if(!a&&!d)throw new Error("Missing gasPrice");let w=new S(z),T=await w.getTransactionCount(o),f=a?{maxFeePerGas:e(i||"0"),maxPriorityFeePerGas:e(c||"0")}:{gasPrice:e(d||"0")},g={to:r.to,data:r.data||"0x",value:e(r.value?.toString()||"0"),gasLimit:e(r.gasLimit?.toString()||"0"),chainId:Number.parseInt(n),nonce:e(T.toString()),...f},{success:l,payload:m}=await t.ethereumSignTransaction({path:u(),transaction:g});if(!l){let F=P[m?.code||""]||m.error;throw new Error(F)}let{r:y,s:v,v:M}=m,x=R.from({...g,nonce:Number.parseInt(g.nonce),type:a?2:0,signature:{r:y,s:v,v:parseInt(M)}}).serialized;return{hash:(await w.broadcastTransaction(x)).hash}}catch(t){throw b(t)}}};export{E as EthereumSigner,b as getTrezorErrorMessage};
2
+ //# sourceMappingURL=ethereum-2ZKMGNFA.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/signers/ethereum.ts"],
4
+ "sourcesContent": ["import type { EvmTransaction } from 'rango-types/mainApi';\n\nimport { cleanEvmError } from '@rango-dev/signer-evm';\nimport { DEFAULT_ETHEREUM_RPC_URL } from '@rango-dev/wallets-shared';\nimport { JsonRpcProvider, Transaction } from 'ethers';\nimport { type GenericSigner } from 'rango-types';\n\nimport {\n getTrezorModule,\n trezorErrorMessages,\n valueToHex,\n} from '../helpers.js';\nimport { getDerivationPath } from '../state.js';\n\nexport function getTrezorErrorMessage(error: any) {\n if (error?.shortMessage) {\n /*\n * Some error signs have lengthy, challenging-to-read messages.\n * shortMessage is used because it is shorter and easier to understand.\n */\n return new Error(error.shortMessage, { cause: error });\n }\n return cleanEvmError(error);\n}\n\nexport class EthereumSigner implements GenericSigner<EvmTransaction> {\n async signMessage(msg: string): Promise<string> {\n const TrezorConnect = await getTrezorModule();\n\n const { success, payload } = await TrezorConnect.ethereumSignMessage({\n message: msg,\n path: getDerivationPath(),\n });\n if (!success) {\n throw new Error(payload.error);\n }\n return payload.signature;\n }\n\n async signAndSendTx(\n tx: EvmTransaction,\n fromAddress: string,\n chainId: string\n ): Promise<{ hash: string }> {\n try {\n const TrezorConnect = await getTrezorModule();\n const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = tx;\n const isEIP1559 = maxFeePerGas && maxPriorityFeePerGas;\n\n if (isEIP1559 && !maxFeePerGas) {\n throw new Error('Missing maxFeePerGas');\n }\n if (isEIP1559 && !maxPriorityFeePerGas) {\n throw new Error('Missing maxPriorityFeePerGas');\n }\n if (!isEIP1559 && !gasPrice) {\n throw new Error('Missing gasPrice');\n }\n const provider = new JsonRpcProvider(DEFAULT_ETHEREUM_RPC_URL); // Provider to broadcast transaction\n const transactionCount = await provider.getTransactionCount(fromAddress); // Get nonce\n const additionalFields = isEIP1559\n ? {\n maxFeePerGas: valueToHex(maxFeePerGas || '0'),\n maxPriorityFeePerGas: valueToHex(maxPriorityFeePerGas || '0'),\n }\n : {\n gasPrice: valueToHex(gasPrice || '0'),\n };\n\n const transaction = {\n to: tx.to,\n data: tx.data || '0x',\n value: valueToHex(tx.value?.toString() || '0'),\n gasLimit: valueToHex(tx.gasLimit?.toString() || '0'),\n chainId: Number.parseInt(chainId),\n nonce: valueToHex(transactionCount.toString()),\n ...additionalFields,\n };\n\n const { success, payload } = await TrezorConnect.ethereumSignTransaction({\n path: getDerivationPath(),\n transaction,\n });\n\n if (!success) {\n const errorMessage =\n trezorErrorMessages[payload?.code || ''] || payload.error;\n throw new Error(errorMessage);\n }\n const { r, s, v } = payload;\n\n const serializedTx = Transaction.from({\n ...transaction,\n nonce: Number.parseInt(transaction.nonce),\n /*\n * Type 0: This refers to the legacy transaction type that has been used since Ethereum's inception.\n * Type 2: This refers to the new transaction type introduced with the EIP-1559 (Ethereum Improvement Proposal 1559) update,\n * which was part of the London hard fork.\n */\n type: isEIP1559 ? 2 : 0,\n signature: { r, s, v: parseInt(v) },\n }).serialized;\n const broadcastResult = await provider.broadcastTransaction(serializedTx);\n\n return { hash: broadcastResult.hash };\n } catch (error) {\n throw getTrezorError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ACP,KAAMA,EAAG,MAAQ,KACjB,MAAOY,EAAWZ,EAAG,OAAO,SAAS,GAAK,GAAG,EAC7C,SAAUY,EAAWZ,EAAG,UAAU,SAAS,GAAK,GAAG,EACnD,QAAS,OAAO,SAASE,CAAO,EAChC,MAAOU,EAAWF,EAAiB,SAAS,CAAC,EAC7C,GAAGC,CACL,EAEM,CAAE,QAAAd,EAAS,QAAAC,CAAQ,EAAI,MAAMH,EAAc,wBAAwB,CACvE,KAAMI,EAAkB,EACxB,YAAAc,CACF,CAAC,EAED,GAAI,CAAChB,EAAS,CACZ,IAAMiB,EACJC,EAAoBjB,GAAS,MAAQ,EAAE,GAAKA,EAAQ,MACtD,MAAM,IAAI,MAAMgB,CAAY,CAC9B,CACA,GAAM,CAAE,EAAAE,EAAG,EAAAC,EAAG,EAAAC,CAAE,EAAIpB,EAEdqB,EAAeC,EAAY,KAAK,CACpC,GAAGP,EACH,MAAO,OAAO,SAASA,EAAY,KAAK,EAMxC,KAAMP,EAAY,EAAI,EACtB,UAAW,CAAE,EAAAU,EAAG,EAAAC,EAAG,EAAG,SAASC,CAAC,CAAE,CACpC,CAAC,EAAE,WAGH,MAAO,CAAE,MAFe,MAAMX,EAAS,qBAAqBY,CAAY,GAEzC,IAAK,CACtC,OAAS7B,EAAO,CACd,MAAMD,EAAsBC,CAAK,CACnC,CACF,CACF",
6
+ "names": ["cleanEvmError", "DEFAULT_ETHEREUM_RPC_URL", "JsonRpcProvider", "Transaction", "getTrezorErrorMessage", "error", "cleanEvmError", "__name", "EthereumSigner", "msg", "TrezorConnect", "getTrezorModule", "success", "payload", "getDerivationPath", "tx", "fromAddress", "chainId", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "isEIP1559", "provider", "JsonRpcProvider", "DEFAULT_ETHEREUM_RPC_URL", "transactionCount", "additionalFields", "valueToHex", "transaction", "errorMessage", "trezorErrorMessages", "r", "s", "v", "serializedTx", "Transaction"]
7
+ }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as r,b as s,e as c,f as p,g as m,i as l}from"./chunk-VKZ2HTGF.js";import{Namespace as g,Networks as d,WalletTypes as v}from"@rango-dev/wallets-shared";import"rango-types";import{DefaultSignerFactory as h,TransactionType as y}from"rango-types";async function i(){let e=new h,{EthereumSigner:t}=await import("./ethereum-UW5V3C7D.js");return e.registerSigner(y.EVM,new t),e}r(i,"getSigners");var u={appUrl:"",email:""},M={type:v.TREZOR},C=r(e=>{u=e.manifest},"init"),I=p,f=!1,D=r(async({namespaces:e})=>{let t=[],a=await c(),n=e?.find(o=>o.namespace===g.Evm);if(n)if(n.derivationPath){s(l(n.derivationPath)),f||(await a.init({lazyLoad:!0,manifest:u}),f=!0);let o=await m();t.push(o)}else throw new Error("Derivation Path can not be empty.");else throw new Error(`It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${e?.map(o=>o.namespace)}`);return t},"connect"),F=i,b=r(e=>{let t=[],a=e.find(n=>n.name===d.ETHEREUM);return a&&t.push(a),{name:"Trezor",img:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg",installLink:{DEFAULT:"https://trezor.io/learn/a/download-verify-trezor-suite"},color:"black",supportedChains:t,namespaces:[g.Evm],singleNamespace:!0,showOnMobile:!1,needsDerivationPath:!0}},"getWalletInfo");export{M as config,D as connect,I as getInstance,F as getSigners,b as getWalletInfo,C as init};
1
+ import{a as r,b as s,e as c,f as p,g as m,i as l}from"./chunk-VKZ2HTGF.js";import{Namespace as g,Networks as d,WalletTypes as v}from"@rango-dev/wallets-shared";import"rango-types";import{DefaultSignerFactory as h,TransactionType as y}from"rango-types";async function i(){let e=new h,{EthereumSigner:t}=await import("./ethereum-2ZKMGNFA.js");return e.registerSigner(y.EVM,new t),e}r(i,"getSigners");var u={appUrl:"",email:""},M={type:v.TREZOR},C=r(e=>{u=e.manifest},"init"),I=p,f=!1,D=r(async({namespaces:e})=>{let t=[],a=await c(),n=e?.find(o=>o.namespace===g.Evm);if(n)if(n.derivationPath){s(l(n.derivationPath)),f||(await a.init({lazyLoad:!0,manifest:u}),f=!0);let o=await m();t.push(o)}else throw new Error("Derivation Path can not be empty.");else throw new Error(`It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${e?.map(o=>o.namespace)}`);return t},"connect"),F=i,b=r(e=>{let t=[],a=e.find(n=>n.name===d.ETHEREUM);return a&&t.push(a),{name:"Trezor",img:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg",installLink:{DEFAULT:"https://trezor.io/learn/a/download-verify-trezor-suite"},color:"black",supportedChains:t,namespaces:[g.Evm],singleNamespace:!0,showOnMobile:!1,needsDerivationPath:!0}},"getWalletInfo");export{M as config,D as connect,I as getInstance,F as getSigners,b as getWalletInfo,C as init};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"inputs":{"src/state.ts":{"bytes":290,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/helpers.ts":{"bytes":2270,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"src/state.ts","kind":"import-statement","original":"./state.js"},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/ethereum.ts":{"bytes":3688,"imports":[{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ethers","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"../helpers.js"},{"path":"src/state.ts","kind":"import-statement","original":"../state.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":394,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/ethereum.ts","kind":"dynamic-import","original":"./signers/ethereum.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":2795,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"},{"path":"src/state.ts","kind":"import-statement","original":"./state.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":5238},"dist/index.js":{"imports":[{"path":"dist/chunk-VKZ2HTGF.js","kind":"import-statement"},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"dist/ethereum-UW5V3C7D.js","kind":"dynamic-import"}],"exports":["config","connect","getInstance","getSigners","getWalletInfo","init"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1016},"src/signer.ts":{"bytesInOutput":218}},"bytes":1439},"dist/ethereum-UW5V3C7D.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6212},"dist/ethereum-UW5V3C7D.js":{"imports":[{"path":"dist/chunk-VKZ2HTGF.js","kind":"import-statement"},{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ethers","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true}],"exports":["EthereumSigner","getTrezorErrorMessage"],"entryPoint":"src/signers/ethereum.ts","inputs":{"src/signers/ethereum.ts":{"bytesInOutput":1383}},"bytes":1553},"dist/chunk-VKZ2HTGF.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4059},"dist/chunk-VKZ2HTGF.js":{"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true}],"exports":["a","b","c","d","e","f","g","h","i"],"inputs":{"src/state.ts":{"bytesInOutput":99},"src/helpers.ts":{"bytesInOutput":737}},"bytes":1030}}}
1
+ {"inputs":{"src/state.ts":{"bytes":290,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/helpers.ts":{"bytes":2270,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"src/state.ts","kind":"import-statement","original":"./state.js"},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/ethereum.ts":{"bytes":3696,"imports":[{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ethers","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"../helpers.js"},{"path":"src/state.ts","kind":"import-statement","original":"../state.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":394,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/ethereum.ts","kind":"dynamic-import","original":"./signers/ethereum.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":2795,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"},{"path":"src/state.ts","kind":"import-statement","original":"./state.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":5238},"dist/index.js":{"imports":[{"path":"dist/chunk-VKZ2HTGF.js","kind":"import-statement"},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"dist/ethereum-2ZKMGNFA.js","kind":"dynamic-import"}],"exports":["config","connect","getInstance","getSigners","getWalletInfo","init"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1016},"src/signer.ts":{"bytesInOutput":218}},"bytes":1439},"dist/ethereum-2ZKMGNFA.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6222},"dist/ethereum-2ZKMGNFA.js":{"imports":[{"path":"dist/chunk-VKZ2HTGF.js","kind":"import-statement"},{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ethers","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true}],"exports":["EthereumSigner","getTrezorErrorMessage"],"entryPoint":"src/signers/ethereum.ts","inputs":{"src/signers/ethereum.ts":{"bytesInOutput":1391}},"bytes":1561},"dist/chunk-VKZ2HTGF.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4059},"dist/chunk-VKZ2HTGF.js":{"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true}],"exports":["a","b","c","d","e","f","g","h","i"],"inputs":{"src/state.ts":{"bytesInOutput":99},"src/helpers.ts":{"bytesInOutput":737}},"bytes":1030}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/provider-trezor",
3
- "version": "0.4.2-next.6",
3
+ "version": "0.5.1-next.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -24,8 +24,8 @@
24
24
  "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
25
25
  },
26
26
  "dependencies": {
27
- "@rango-dev/signer-evm": "^0.30.1-next.0",
28
- "@rango-dev/wallets-shared": "^0.37.1-next.4",
27
+ "@rango-dev/signer-evm": "^0.31.0",
28
+ "@rango-dev/wallets-shared": "^0.38.0",
29
29
  "@trezor/connect-web": "^9.2.4",
30
30
  "ethers": "^6.13.2",
31
31
  "rango-types": "^0.1.74"
@@ -33,4 +33,4 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  }
36
- }
36
+ }
@@ -27,7 +27,7 @@ export class EthereumSigner implements GenericSigner<EvmTransaction> {
27
27
  async signMessage(msg: string): Promise<string> {
28
28
  const TrezorConnect = await getTrezorModule();
29
29
 
30
- const { success, payload } = await TrezorConnect.signMessage({
30
+ const { success, payload } = await TrezorConnect.ethereumSignMessage({
31
31
  message: msg,
32
32
  path: getDerivationPath(),
33
33
  });
@@ -1,2 +0,0 @@
1
- import{a as p,c as u,d as P,e as d,h as e}from"./chunk-VKZ2HTGF.js";import{cleanEvmError as G}from"@rango-dev/signer-evm";import{DEFAULT_ETHEREUM_RPC_URL as z}from"@rango-dev/wallets-shared";import{JsonRpcProvider as R,Transaction as S}from"ethers";import"rango-types";function b(t){return t?.shortMessage?new Error(t.shortMessage,{cause:t}):G(t)}p(b,"getTrezorErrorMessage");var E=class{static{p(this,"EthereumSigner")}async signMessage(r){let o=await d(),{success:n,payload:s}=await o.signMessage({message:r,path:u()});if(!n)throw new Error(s.error);return s.signature}async signAndSendTx(r,o,n){try{let s=await d(),{gasPrice:h,maxFeePerGas:i,maxPriorityFeePerGas:c}=r,a=i&&c;if(a&&!i)throw new Error("Missing maxFeePerGas");if(a&&!c)throw new Error("Missing maxPriorityFeePerGas");if(!a&&!h)throw new Error("Missing gasPrice");let w=new R(z),T=await w.getTransactionCount(o),f=a?{maxFeePerGas:e(i||"0"),maxPriorityFeePerGas:e(c||"0")}:{gasPrice:e(h||"0")},g={to:r.to,data:r.data||"0x",value:e(r.value?.toString()||"0"),gasLimit:e(r.gasLimit?.toString()||"0"),chainId:Number.parseInt(n),nonce:e(T.toString()),...f},{success:l,payload:m}=await s.ethereumSignTransaction({path:u(),transaction:g});if(!l){let F=P[m?.code||""]||m.error;throw new Error(F)}let{r:y,s:v,v:M}=m,x=S.from({...g,nonce:Number.parseInt(g.nonce),type:a?2:0,signature:{r:y,s:v,v:parseInt(M)}}).serialized;return{hash:(await w.broadcastTransaction(x)).hash}}catch(s){throw b(s)}}};export{E as EthereumSigner,b as getTrezorErrorMessage};
2
- //# sourceMappingURL=ethereum-UW5V3C7D.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/signers/ethereum.ts"],
4
- "sourcesContent": ["import type { EvmTransaction } from 'rango-types/mainApi';\n\nimport { cleanEvmError } from '@rango-dev/signer-evm';\nimport { DEFAULT_ETHEREUM_RPC_URL } from '@rango-dev/wallets-shared';\nimport { JsonRpcProvider, Transaction } from 'ethers';\nimport { type GenericSigner } from 'rango-types';\n\nimport {\n getTrezorModule,\n trezorErrorMessages,\n valueToHex,\n} from '../helpers.js';\nimport { getDerivationPath } from '../state.js';\n\nexport function getTrezorErrorMessage(error: any) {\n if (error?.shortMessage) {\n /*\n * Some error signs have lengthy, challenging-to-read messages.\n * shortMessage is used because it is shorter and easier to understand.\n */\n return new Error(error.shortMessage, { cause: error });\n }\n return cleanEvmError(error);\n}\n\nexport class EthereumSigner implements GenericSigner<EvmTransaction> {\n async signMessage(msg: string): Promise<string> {\n const TrezorConnect = await getTrezorModule();\n\n const { success, payload } = await TrezorConnect.signMessage({\n message: msg,\n path: getDerivationPath(),\n });\n if (!success) {\n throw new Error(payload.error);\n }\n return payload.signature;\n }\n\n async signAndSendTx(\n tx: EvmTransaction,\n fromAddress: string,\n chainId: string\n ): Promise<{ hash: string }> {\n try {\n const TrezorConnect = await getTrezorModule();\n const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = tx;\n const isEIP1559 = maxFeePerGas && maxPriorityFeePerGas;\n\n if (isEIP1559 && !maxFeePerGas) {\n throw new Error('Missing maxFeePerGas');\n }\n if (isEIP1559 && !maxPriorityFeePerGas) {\n throw new Error('Missing maxPriorityFeePerGas');\n }\n if (!isEIP1559 && !gasPrice) {\n throw new Error('Missing gasPrice');\n }\n const provider = new JsonRpcProvider(DEFAULT_ETHEREUM_RPC_URL); // Provider to broadcast transaction\n const transactionCount = await provider.getTransactionCount(fromAddress); // Get nonce\n const additionalFields = isEIP1559\n ? {\n maxFeePerGas: valueToHex(maxFeePerGas || '0'),\n maxPriorityFeePerGas: valueToHex(maxPriorityFeePerGas || '0'),\n }\n : {\n gasPrice: valueToHex(gasPrice || '0'),\n };\n\n const transaction = {\n to: tx.to,\n data: tx.data || '0x',\n value: valueToHex(tx.value?.toString() || '0'),\n gasLimit: valueToHex(tx.gasLimit?.toString() || '0'),\n chainId: Number.parseInt(chainId),\n nonce: valueToHex(transactionCount.toString()),\n ...additionalFields,\n };\n\n const { success, payload } = await TrezorConnect.ethereumSignTransaction({\n path: getDerivationPath(),\n transaction,\n });\n\n if (!success) {\n const errorMessage =\n trezorErrorMessages[payload?.code || ''] || payload.error;\n throw new Error(errorMessage);\n }\n const { r, s, v } = payload;\n\n const serializedTx = Transaction.from({\n ...transaction,\n nonce: Number.parseInt(transaction.nonce),\n /*\n * Type 0: This refers to the legacy transaction type that has been used since Ethereum's inception.\n * Type 2: This refers to the new transaction type introduced with the EIP-1559 (Ethereum Improvement Proposal 1559) update,\n * which was part of the London hard fork.\n */\n type: isEIP1559 ? 2 : 0,\n signature: { r, s, v: parseInt(v) },\n }).serialized;\n const broadcastResult = await provider.broadcastTransaction(serializedTx);\n\n return { hash: broadcastResult.hash };\n } catch (error) {\n throw getTrezorErrorMessage(error);\n }\n }\n}\n"],
5
- "mappings": "oEAEA,OAAS,iBAAAA,MAAqB,wBAC9B,OAAS,4BAAAC,MAAgC,4BACzC,OAAS,mBAAAC,EAAiB,eAAAC,MAAmB,SAC7C,MAAmC,cAS5B,SAASC,EAAsBC,EAAY,CAChD,OAAIA,GAAO,aAKF,IAAI,MAAMA,EAAM,aAAc,CAAE,MAAOA,CAAM,CAAC,EAEhDC,EAAcD,CAAK,CAC5B,CATgBE,EAAAH,EAAA,yBAWT,IAAMI,EAAN,KAA8D,CAzBrE,MAyBqE,CAAAD,EAAA,uBACnE,MAAM,YAAYE,EAA8B,CAC9C,IAAMC,EAAgB,MAAMC,EAAgB,EAEtC,CAAE,QAAAC,E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CAC9B,CACA,GAAM,CAAE,EAAAE,EAAG,EAAAC,EAAG,EAAAC,CAAE,EAAIpB,EAEdqB,EAAeC,EAAY,KAAK,CACpC,GAAGP,EACH,MAAO,OAAO,SAASA,EAAY,KAAK,EAMxC,KAAMP,EAAY,EAAI,EACtB,UAAW,CAAE,EAAAU,EAAG,EAAAC,EAAG,EAAG,SAASC,CAAC,CAAE,CACpC,CAAC,EAAE,WAGH,MAAO,CAAE,MAFe,MAAMX,EAAS,qBAAqBY,CAAY,GAEzC,IAAK,CACtC,OAAS7B,EAAO,CACd,MAAMD,EAAsBC,CAAK,CACnC,CACF,CACF",
6
- "names": ["cleanEvmError", "DEFAULT_ETHEREUM_RPC_URL", "JsonRpcProvider", "Transaction", "getTrezorErrorMessage", "error", "cleanEvmError", "__name", "EthereumSigner", "msg", "TrezorConnect", "getTrezorModule", "success", "payload", "getDerivationPath", "tx", "fromAddress", "chainId", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "isEIP1559", "provider", "JsonRpcProvider", "DEFAULT_ETHEREUM_RPC_URL", "transactionCount", "additionalFields", "valueToHex", "transaction", "errorMessage", "trezorErrorMessages", "r", "s", "v", "serializedTx", "Transaction"]
7
- }