@rango-dev/signer-evm 0.45.1-next.0 → 0.46.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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { DefaultEvmSigner } from './signer.js';
2
2
  export { waitMs, cleanEvmError, toHexQuantity } from './helper.js';
3
3
  export { DEFAULT_ETHEREUM_RPC_URL } from './constants.js';
4
+ export type { TypedData } from './types.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var P=Object.defineProperty;var a=(e,r)=>P(e,"name",{value:r,configurable:!0});import{BrowserProvider as C,isError as y}from"ethers";import{RPCErrorCode as O,SignerError as g,SignerErrorCode as E}from"rango-types";import{isError as l,toQuantity as N}from"ethers";import{RPCErrorCode as p,SignerError as d,SignerErrorCode as u}from"rango-types";var h=a(e=>{if(!e)return new d(u.SEND_TX_ERROR);if(d.isSignerError(e))return e;if(e.code){if(l(e,"UNKNOWN_ERROR")){let t=e.error?.message||e.message;return new d(u.SEND_TX_ERROR,void 0,t,p.UNKNOWN_ERROR,e)}if(l(e,"ACTION_REJECTED")){let t=e.shortMessage.replace("action",`'${e.action}'`);return new d(u.SEND_TX_ERROR,void 0,t,p.REJECTION,e)}let r=e.shortMessage||e.message;return new d(u.SEND_TX_ERROR,void 0,r,p.UNKNOWN_ERROR,e)}return new d(u.SEND_TX_ERROR,void 0,e,p.UNKNOWN_ERROR,e)},"cleanEvmError");async function T(e,r){if(!e||!r)return;let t=parseInt(e);try{let o=`https://api.tenderly.co/api/v1/public-contract/${t}/tx/${r}`,n=await fetch(o,{method:"GET"});return n.ok?(await n.json())?.error_message:void 0}catch{return}}a(T,"getTenderlyError");var S=a(e=>N(e),"toHexQuantity"),m=a(async e=>new Promise(r=>setTimeout(r,e)),"waitMs");var I=a(async(e,r,t,o)=>{let i=!1;return await Promise.race([(async()=>{await r.wait(o),i=!0})(),(async()=>{for(;!i;){if(await m(3e3),i)return null;try{if(!await e.getTransaction(t))return null}catch(s){return console.log({error:s}),null}}return null})()])},"waitWithMempoolCheck"),R=class e{static{a(this,"DefaultEvmSigner")}provider;constructor(r){this.provider=new C(r)}static buildTx(r,t=!1){let n={};return n={data:r.data||"0x"},r.from&&(n={...n,from:r.from}),r.to&&(n={...n,to:r.to}),r.value&&(n={...n,value:r.value}),r.nonce&&(n={...n,nonce:parseInt(r.nonce)}),r.gasLimit&&(n={...n,gasLimit:r.gasLimit}),!t&&r.maxFeePerGas&&r.maxPriorityFeePerGas?n={...n,maxFeePerGas:r.maxFeePerGas,maxPriorityFeePerGas:r.maxPriorityFeePerGas}:r.gasPrice&&(n={...n,gasPrice:"0x"+parseInt(r.gasPrice).toString(16)}),n}async signTypedData(r){try{return await(await this.provider.getSigner()).signTypedData(r.domain,r.types,r.value)}catch(t){throw new g(E.SIGN_TX_ERROR,void 0,t)}}async signMessage(r){try{return await(await this.provider.getSigner()).signMessage(r)}catch(t){throw new g(E.SIGN_TX_ERROR,void 0,t)}}async signAndSendTx(r,t,o){try{let n=await this.provider.getSigner(r.from??void 0),i=e.buildTx(r),s=(await this.provider.getNetwork()).chainId,f=await n.getAddress();if(o&&s&&s.toString()!==Number(o).toString())throw new g(E.UNEXPECTED_BEHAVIOUR,void 0,`Signer chainId: '${s}' doesn't match with required chainId: '${o}' for tx.`);if(f&&t&&f.toLowerCase()!==t.toLowerCase())throw new g(E.UNEXPECTED_BEHAVIOUR,void 0,`Signer address: '${f.toLowerCase()}' doesn't match with required address: '${t.toLowerCase()}' for tx.`);try{let c=await n.sendTransaction(i);return{hash:c.hash,response:c}}catch(c){if(c?.message&&typeof c.message=="string"&&c.message.indexOf("EIP-1559")!==-1){console.log("retrying EIP-1559 error without v2 fields ...");let _=e.buildTx(r,!0),w=await n.sendTransaction(_);return{hash:w.hash,response:w}}throw c}}catch(n){throw h(n)}}async wait(r,t,o,n){try{if(o)return await o?.wait(n),{hash:r};if(!this.provider)return{hash:r};if(!t)return{hash:r};let i=(await this.provider.getNetwork()).chainId;if(!i||Number(t).toString()!==i.toString())return{hash:r};let s=await this.provider.getTransaction(r);if(!s)throw Error(`Transaction hash '${r}' not found in blockchain.`);return await I(this.provider,s,r,n),{hash:r}}catch(i){if(y(i,"TRANSACTION_REPLACED")){if(i.reason==="cancelled")throw new g(E.SEND_TX_ERROR,void 0,"Transaction replaced and canceled by user",void 0,i);return{hash:i.replacement.hash,response:i.replacement}}else if(y(i,"CALL_EXCEPTION")){let s=await T(t,r);if(s)throw new g(E.TX_FAILED_IN_BLOCKCHAIN,"Trannsaction failed in blockchain",s,O.CALL_EXCEPTION,i);return{hash:r}}return{hash:r}}}};var A="https://rpc.ankr.com/eth/8d43f5e842676d766141cb1943b9b4e12821f463665e180c209bd3dab9639df2";export{A as DEFAULT_ETHEREUM_RPC_URL,R as DefaultEvmSigner,h as cleanEvmError,S as toHexQuantity,m as waitMs};
1
+ var P=Object.defineProperty;var a=(e,r)=>P(e,"name",{value:r,configurable:!0});import{BrowserProvider as C,isError as y}from"ethers";import{RPCErrorCode as O,SignerError as g,SignerErrorCode as E}from"rango-types";import{isError as l,toQuantity as N}from"ethers";import{RPCErrorCode as u,SignerError as d,SignerErrorCode as p}from"rango-types";var h=a(e=>{if(!e)return new d(p.SEND_TX_ERROR);if(d.isSignerError(e))return e;if(e.code){if(l(e,"UNKNOWN_ERROR")){let t=e.error?.message||e.message;return new d(p.SEND_TX_ERROR,void 0,t,u.UNKNOWN_ERROR,e)}if(l(e,"ACTION_REJECTED")){let t=e.shortMessage.replace("action",`'${e.action}'`);return new d(p.SEND_TX_ERROR,void 0,t,u.REJECTION,e)}let r=e.shortMessage||e.message;return new d(p.SEND_TX_ERROR,void 0,r,u.UNKNOWN_ERROR,e)}return new d(p.SEND_TX_ERROR,void 0,e,u.UNKNOWN_ERROR,e)},"cleanEvmError");async function T(e,r){if(!e||!r)return;let t=parseInt(e);try{let o=`https://api.tenderly.co/api/v1/public-contract/${t}/tx/${r}`,n=await fetch(o,{method:"GET"});return n.ok?(await n.json())?.error_message:void 0}catch{return}}a(T,"getTenderlyError");var S=a(e=>N(e),"toHexQuantity"),m=a(async e=>new Promise(r=>setTimeout(r,e)),"waitMs");var I=a(async(e,r,t,o)=>{let i=!1;return await Promise.race([(async()=>{await r.wait(o),i=!0})(),(async()=>{for(;!i;){if(await m(3e3),i)return null;try{if(!await e.getTransaction(t))return null}catch(s){return console.log({error:s}),null}}return null})()])},"waitWithMempoolCheck"),R=class e{static{a(this,"DefaultEvmSigner")}provider;constructor(r){this.provider=new C(r)}static buildTx(r,t=!1){let n={};return n={data:r.data||"0x"},r.from&&(n={...n,from:r.from}),r.to&&(n={...n,to:r.to}),r.value&&(n={...n,value:r.value}),r.nonce&&(n={...n,nonce:parseInt(r.nonce)}),r.gasLimit&&(n={...n,gasLimit:r.gasLimit}),!t&&r.maxFeePerGas&&r.maxPriorityFeePerGas?n={...n,maxFeePerGas:r.maxFeePerGas,maxPriorityFeePerGas:r.maxPriorityFeePerGas}:r.gasPrice&&(n={...n,gasPrice:"0x"+parseInt(r.gasPrice).toString(16)}),n}async signTypedData(r){try{return await(await this.provider.getSigner()).signTypedData(r.domain,r.types,r.value)}catch(t){throw new g(E.SIGN_TX_ERROR,void 0,t)}}async signMessage(r){try{return await(await this.provider.getSigner()).signMessage(r)}catch(t){throw new g(E.SIGN_TX_ERROR,void 0,t)}}async signAndSendTx(r,t,o){try{let n=await this.provider.getSigner(r.from??void 0),i=e.buildTx(r),s=(await this.provider.getNetwork()).chainId,f=await n.getAddress();if(o&&s&&s.toString()!==Number(o).toString())throw new g(E.UNEXPECTED_BEHAVIOUR,void 0,`Signer chainId: '${s}' doesn't match with required chainId: '${o}' for tx.`);if(f&&t&&f.toLowerCase()!==t.toLowerCase())throw new g(E.UNEXPECTED_BEHAVIOUR,void 0,`Signer address: '${f.toLowerCase()}' doesn't match with required address: '${t.toLowerCase()}' for tx.`);try{let c=await n.sendTransaction(i);return{hash:c.hash,response:c}}catch(c){if(c?.message&&typeof c.message=="string"&&c.message.indexOf("EIP-1559")!==-1){console.log("retrying EIP-1559 error without v2 fields ...");let _=e.buildTx(r,!0),w=await n.sendTransaction(_);return{hash:w.hash,response:w}}throw c}}catch(n){throw h(n)}}async wait(r,t,o,n){try{if(o)return await o?.wait(n),{hash:r};if(!this.provider)return{hash:r};if(!t)return{hash:r};let i=(await this.provider.getNetwork()).chainId;if(!i||Number(t).toString()!==i.toString())return{hash:r};let s=await this.provider.getTransaction(r);if(!s)throw Error(`Transaction hash '${r}' not found in blockchain.`);return await I(this.provider,s,r,n),{hash:r}}catch(i){if(y(i,"TRANSACTION_REPLACED")){if(i.reason==="cancelled")throw new g(E.SEND_TX_ERROR,void 0,"Transaction replaced and canceled by user",void 0,i);return{hash:i.replacement.hash,response:i.replacement}}else if(y(i,"CALL_EXCEPTION")){let s=await T(t,r);if(s)throw new g(E.TX_FAILED_IN_BLOCKCHAIN,"Trannsaction failed in blockchain",s,O.CALL_EXCEPTION,i);return{hash:r}}return{hash:r}}}};var A="https://rpc.ankr.com/eth/8d43f5e842676d766141cb1943b9b4e12821f463665e180c209bd3dab9639df2";export{A as DEFAULT_ETHEREUM_RPC_URL,R as DefaultEvmSigner,h as cleanEvmError,S as toHexQuantity,m as waitMs};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/signer-evm",
3
- "version": "0.45.1-next.0",
3
+ "version": "0.46.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { DefaultEvmSigner } from './signer.js';
2
2
  export { waitMs, cleanEvmError, toHexQuantity } from './helper.js';
3
3
  export { DEFAULT_ETHEREUM_RPC_URL } from './constants.js';
4
+ export type { TypedData } from './types.js';
package/CHANGELOG.md DELETED
@@ -1,191 +0,0 @@
1
- # [0.45.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.44.0...signer-evm@0.45.0) (2026-08-18)
2
-
3
-
4
-
5
- # [0.44.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.43.0...signer-evm@0.44.0) (2026-07-28)
6
-
7
-
8
- ### Bug Fixes
9
-
10
- * **walletconnect:** send eth_sendTransaction params as hex ([57141a8](https://github.com/rango-exchange/rango-client/commit/57141a85ce9548038f4fe527407cbf5cfcfb7383))
11
-
12
-
13
-
14
- # [0.43.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.42.0...signer-evm@0.43.0) (2026-07-07)
15
-
16
-
17
- ### Features
18
-
19
- * add support for hyperliquid transactions ([88630bc](https://github.com/rango-exchange/rango-client/commit/88630bcf6dfa67d57e6cd002da4106142785946f))
20
-
21
-
22
-
23
- # [0.42.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.41.1...signer-evm@0.42.0) (2026-05-31)
24
-
25
-
26
-
27
- ## [0.41.1](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.41.0...signer-evm@0.41.1) (2026-05-02)
28
-
29
-
30
-
31
- # [0.41.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.40.0...signer-evm@0.41.0) (2026-04-29)
32
-
33
-
34
-
35
- # [0.40.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.39.0...signer-evm@0.40.0) (2025-08-19)
36
-
37
-
38
-
39
- # [0.39.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.38.0...signer-evm@0.39.0) (2025-08-05)
40
-
41
-
42
-
43
- # [0.38.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.37.0...signer-evm@0.38.0) (2025-07-22)
44
-
45
-
46
- ### Reverts
47
-
48
- * Revert "chore(release): publish" ([064ce15](https://github.com/rango-exchange/rango-client/commit/064ce157a2f819856f647f83aeb1c0410542e8d7))
49
-
50
-
51
-
52
- # [0.36.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.35.0...signer-evm@0.36.0) (2025-06-09)
53
-
54
-
55
-
56
- # [0.35.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.34.0...signer-evm@0.35.0) (2025-04-30)
57
-
58
-
59
- ### Bug Fixes
60
-
61
- * rename pbt to ptb for sui ([3d6d89f](https://github.com/rango-exchange/rango-client/commit/3d6d89f2265766607a15d61e0df92643fb33072b))
62
-
63
-
64
- ### Features
65
-
66
- * update sui to consider recent api changes ([d764b25](https://github.com/rango-exchange/rango-client/commit/d764b2501df9bb295f63cdbc0b05acd4a3abb4b9))
67
-
68
-
69
-
70
- # [0.34.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.33.0...signer-evm@0.34.0) (2025-03-11)
71
-
72
-
73
-
74
- # [0.33.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.32.0...signer-evm@0.33.0) (2025-02-23)
75
-
76
-
77
-
78
- # [0.32.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.31.0...signer-evm@0.32.0) (2024-11-12)
79
-
80
-
81
-
82
- # [0.31.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.30.0...signer-evm@0.31.0) (2024-10-12)
83
-
84
-
85
- ### Bug Fixes
86
-
87
- * bump sdk and fix type issues ([d442208](https://github.com/rango-exchange/rango-client/commit/d4422083bf5dd27d5f509ce1db7f9560d05428c8))
88
-
89
-
90
-
91
- # [0.30.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.29.0...signer-evm@0.30.0) (2024-09-10)
92
-
93
-
94
-
95
- # [0.29.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.28.0...signer-evm@0.29.0) (2024-08-11)
96
-
97
-
98
-
99
- # [0.28.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.27.1...signer-evm@0.28.0) (2024-07-09)
100
-
101
-
102
- ### Bug Fixes
103
-
104
- * fix tx data for evm signers when transfering native tokens ([a5d9f6e](https://github.com/rango-exchange/rango-client/commit/a5d9f6e3f5bada210a05c0d1f5c57d7917bf869c))
105
-
106
-
107
-
108
- ## [0.27.1](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.27.0...signer-evm@0.27.1) (2024-05-26)
109
-
110
-
111
-
112
- # [0.27.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.26.0...signer-evm@0.27.0) (2024-05-25)
113
-
114
-
115
- ### Bug Fixes
116
-
117
- * exclude the gas price from evm transaction specifications in version 2 ([49c5005](https://github.com/rango-exchange/rango-client/commit/49c50058f717f439833fe4cff216e5a45fbe252d))
118
-
119
-
120
-
121
- # [0.26.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.25.0...signer-evm@0.26.0) (2024-02-20)
122
-
123
-
124
-
125
- # [0.25.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.23.0...signer-evm@0.25.0) (2023-12-24)
126
-
127
-
128
- ### Bug Fixes
129
-
130
- * fix HMR for widget and playground ([8524820](https://github.com/rango-exchange/rango-client/commit/8524820f10cf0b8921f3db0c4f620ff98daa4103))
131
-
132
-
133
-
134
- # [0.14.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.13.0...signer-evm@0.14.0) (2023-08-03)
135
-
136
-
137
-
138
- # [0.13.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.12.0...signer-evm@0.13.0) (2023-08-01)
139
-
140
-
141
-
142
- # [0.9.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.8.0...signer-evm@0.9.0) (2023-07-31)
143
-
144
-
145
- ### Features
146
-
147
- * Support for WalletConnect 2 ([faedef0](https://github.com/rango-exchange/rango-client/commit/faedef0b5e6fc3c5ef881cbbe4ec05334cc1c910))
148
- * support safe wallet ([d04cbcd](https://github.com/rango-exchange/rango-client/commit/d04cbcd2a612755563512d9dff6f2312088d8b4d))
149
-
150
-
151
-
152
- # [0.7.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.6.0...signer-evm@0.7.0) (2023-07-11)
153
-
154
-
155
-
156
- # [0.6.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.5.0...signer-evm@0.6.0) (2023-07-11)
157
-
158
-
159
- ### Bug Fixes
160
-
161
- * better parsing of evm rpc errors ([f23031a](https://github.com/rango-exchange/rango-client/commit/f23031ae14e6e841ee488591bd1bf58cfa7ca15b))
162
- * fix signer wait change network issues ([e453db6](https://github.com/rango-exchange/rango-client/commit/e453db6ccf7736e36e5ada0c29502be32254fe9c))
163
- * show tenderly error on call exception ([c218f49](https://github.com/rango-exchange/rango-client/commit/c218f49f3330706d9262b0cf3ec8e293e91e3729))
164
-
165
-
166
-
167
- # [0.5.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.4.0...signer-evm@0.5.0) (2023-05-31)
168
-
169
-
170
-
171
- # [0.4.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.3.0...signer-evm@0.4.0) (2023-05-31)
172
-
173
-
174
-
175
- # [0.3.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.2.0...signer-evm@0.3.0) (2023-05-30)
176
-
177
-
178
-
179
- # [0.2.0](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.1.14...signer-evm@0.2.0) (2023-05-30)
180
-
181
-
182
-
183
- ## [0.1.13](https://github.com/rango-exchange/rango-client/compare/signer-evm@0.1.12...signer-evm@0.1.13) (2023-05-15)
184
-
185
-
186
- ### Bug Fixes
187
-
188
- * update rango-types and fix notification bugs ([993f185](https://github.com/rango-exchange/rango-client/commit/993f185e0b8c5e5e15a2c65ba2d85d1f9c8daa90))
189
-
190
-
191
-