@meshconnect/uwc-wallet-connect-connector 0.13.0 → 0.14.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/dist/services/ethereum/ethereum-transaction-builder.d.ts.map +1 -1
- package/dist/services/ethereum/ethereum-transaction-builder.js +3 -2
- package/dist/services/ethereum/ethereum-transaction-builder.js.map +1 -1
- package/package.json +2 -2
- package/src/services/ethereum/ethereum-transaction-builder.test.ts +97 -0
- package/src/services/ethereum/ethereum-transaction-builder.ts +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum-transaction-builder.d.ts","sourceRoot":"","sources":["../../../src/services/ethereum/ethereum-transaction-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"ethereum-transaction-builder.d.ts","sourceRoot":"","sources":["../../../src/services/ethereum/ethereum-transaction-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAA;AAI/B;;GAEG;AACH,qBAAa,0BAA0B;IAC/B,sBAAsB,CAC1B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAuB1B,oBAAoB,CACxB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,oBAAoB,CAAC;IAa1B,kBAAkB,CACtB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAgBhC;;OAEG;IACH,OAAO,CAAC,eAAe;CAmBxB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { encodeFunctionData } from 'viem';
|
|
2
|
+
import { toEvmValueBigInt } from '@meshconnect/uwc-types';
|
|
2
3
|
import { parseError } from '../../utils/error-utils';
|
|
3
4
|
/**
|
|
4
5
|
* Service for handling Ethereum/EVM transaction operations
|
|
@@ -16,7 +17,7 @@ export class EthereumTransactionBuilder {
|
|
|
16
17
|
from: request.from,
|
|
17
18
|
to: request.contractAddress,
|
|
18
19
|
data,
|
|
19
|
-
value: request.value
|
|
20
|
+
value: toEvmValueBigInt(request.value),
|
|
20
21
|
...this.formatGasConfig(request.gasConfig)
|
|
21
22
|
};
|
|
22
23
|
return txRequest;
|
|
@@ -44,7 +45,7 @@ export class EthereumTransactionBuilder {
|
|
|
44
45
|
from: request.from,
|
|
45
46
|
to: request.to,
|
|
46
47
|
data: request.data,
|
|
47
|
-
value: request.value
|
|
48
|
+
value: toEvmValueBigInt(request.value),
|
|
48
49
|
...this.formatGasConfig(request.gasConfig)
|
|
49
50
|
};
|
|
50
51
|
return txRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum-transaction-builder.js","sourceRoot":"","sources":["../../../src/services/ethereum/ethereum-transaction-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAQzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,sBAAsB,CAC1B,OAA+B;QAE/B,IAAI,CAAC;YACH,kCAAkC;YAClC,MAAM,IAAI,GAAG,kBAAkB,CAAC;gBAC9B,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;aACzB,CAAC,CAAA;YAEF,MAAM,SAAS,GAAyB;gBACtC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,EAAE,EAAE,OAAO,CAAC,eAAe;gBAC3B,IAAI;gBACJ,KAAK,EAAE,OAAO,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"ethereum-transaction-builder.js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C;IAED,KAAK,CAAC,kBAAkB,CACtB,OAA+B;QAE/B,IAAI,CAAC;YACH,MAAM,SAAS,GAAyB;gBACtC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC;gBACtC,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC;aAC3C,CAAA;YAED,OAAO,SAAS,CAAA;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,UAAU,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IAED;;OAEG;IACK,eAAe,CACrB,SAAwB;QAExB,MAAM,SAAS,GAAkC,EAAE,CAAA;QAEnD,IAAI,SAAS,EAAE,QAAQ,EAAE,CAAC;YACxB,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC7D,CAAC;QACD,IAAI,SAAS,EAAE,YAAY,EAAE,CAAC;YAC5B,SAAS,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAA;QACrE,CAAC;QACD,IAAI,SAAS,EAAE,oBAAoB,EAAE,CAAC;YACpC,SAAS,CAAC,oBAAoB,GAAG,MAAM,CACrC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QACH,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshconnect/uwc-wallet-connect-connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "WalletConnect connector for Universal Wallet Connector",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"bs58": "6.0.0",
|
|
26
26
|
"buffer": "^6.0.3",
|
|
27
27
|
"viem": "^2.54.6",
|
|
28
|
-
"@meshconnect/uwc-types": "0.
|
|
28
|
+
"@meshconnect/uwc-types": "0.26.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.9.3"
|
|
@@ -286,4 +286,101 @@ describe('WalletConnect EthereumTransactionBuilder', () => {
|
|
|
286
286
|
expect(result.maxPriorityFeePerGas).toBe(BigInt(2000000000))
|
|
287
287
|
})
|
|
288
288
|
})
|
|
289
|
+
|
|
290
|
+
describe('value normalization', () => {
|
|
291
|
+
const oneEth = 1000000000000000000n
|
|
292
|
+
const from = '0x1234567890123456789012345678901234567890'
|
|
293
|
+
const to = '0x0987654321098765432109876543210987654321'
|
|
294
|
+
const cases: [string, bigint | string][] = [
|
|
295
|
+
['bigint', oneEth],
|
|
296
|
+
['decimal string', '1000000000000000000'],
|
|
297
|
+
['hex string', '0xde0b6b3a7640000']
|
|
298
|
+
]
|
|
299
|
+
|
|
300
|
+
it.each(cases)(
|
|
301
|
+
'contract-call value as %s normalizes to bigint',
|
|
302
|
+
async (_l, value) => {
|
|
303
|
+
const result = await builder.getContractTransaction({
|
|
304
|
+
from,
|
|
305
|
+
contractAddress: to,
|
|
306
|
+
abi: [
|
|
307
|
+
{
|
|
308
|
+
inputs: [],
|
|
309
|
+
name: 'deposit',
|
|
310
|
+
outputs: [],
|
|
311
|
+
stateMutability: 'payable',
|
|
312
|
+
type: 'function'
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
functionName: 'deposit',
|
|
316
|
+
args: [],
|
|
317
|
+
value
|
|
318
|
+
})
|
|
319
|
+
expect(result.value).toBe(oneEth)
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
it.each(cases)(
|
|
324
|
+
'data-transfer value as %s normalizes to bigint',
|
|
325
|
+
async (_l, value) => {
|
|
326
|
+
const result = await builder.getDataTransaction({
|
|
327
|
+
from,
|
|
328
|
+
to,
|
|
329
|
+
data: '0x',
|
|
330
|
+
chainId: '1',
|
|
331
|
+
value
|
|
332
|
+
})
|
|
333
|
+
expect(result.value).toBe(oneEth)
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
it('defaults a missing value to 0n', async () => {
|
|
338
|
+
const result = await builder.getDataTransaction({
|
|
339
|
+
from,
|
|
340
|
+
to,
|
|
341
|
+
data: '0x',
|
|
342
|
+
chainId: '1'
|
|
343
|
+
})
|
|
344
|
+
expect(result.value).toBe(0n)
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
it.each(['', ' ', 'abc', '1.5', '0x'])(
|
|
348
|
+
'rejects an invalid data-transfer value %j instead of coercing to 0',
|
|
349
|
+
async value => {
|
|
350
|
+
await expect(
|
|
351
|
+
builder.getDataTransaction({
|
|
352
|
+
from,
|
|
353
|
+
to,
|
|
354
|
+
data: '0x',
|
|
355
|
+
chainId: '1',
|
|
356
|
+
value
|
|
357
|
+
})
|
|
358
|
+
).rejects.toThrow(/Invalid EVM value/)
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
it.each(['', ' ', 'abc', '1.5', '0x'])(
|
|
363
|
+
'rejects an invalid contract-call value %j instead of coercing to 0',
|
|
364
|
+
async value => {
|
|
365
|
+
await expect(
|
|
366
|
+
builder.getContractTransaction({
|
|
367
|
+
from,
|
|
368
|
+
contractAddress: to,
|
|
369
|
+
abi: [
|
|
370
|
+
{
|
|
371
|
+
inputs: [],
|
|
372
|
+
name: 'deposit',
|
|
373
|
+
outputs: [],
|
|
374
|
+
stateMutability: 'payable',
|
|
375
|
+
type: 'function'
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
functionName: 'deposit',
|
|
379
|
+
args: [],
|
|
380
|
+
value
|
|
381
|
+
})
|
|
382
|
+
).rejects.toThrow(/Invalid EVM value/)
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
})
|
|
289
386
|
})
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
EVMTransactionParams,
|
|
7
7
|
EVMDataTransferRequest
|
|
8
8
|
} from '@meshconnect/uwc-types'
|
|
9
|
+
import { toEvmValueBigInt } from '@meshconnect/uwc-types'
|
|
9
10
|
import { parseError } from '../../utils/error-utils'
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -27,7 +28,7 @@ export class EthereumTransactionBuilder {
|
|
|
27
28
|
from: request.from,
|
|
28
29
|
to: request.contractAddress,
|
|
29
30
|
data,
|
|
30
|
-
value: request.value
|
|
31
|
+
value: toEvmValueBigInt(request.value),
|
|
31
32
|
...this.formatGasConfig(request.gasConfig)
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -60,7 +61,7 @@ export class EthereumTransactionBuilder {
|
|
|
60
61
|
from: request.from,
|
|
61
62
|
to: request.to,
|
|
62
63
|
data: request.data,
|
|
63
|
-
value: request.value
|
|
64
|
+
value: toEvmValueBigInt(request.value),
|
|
64
65
|
...this.formatGasConfig(request.gasConfig)
|
|
65
66
|
}
|
|
66
67
|
|