@0xsequence/wallet-primitives 3.0.0-beta.1 → 3.0.0-beta.3

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @0xsequence/wallet-primitives@3.0.0-beta.1 build /Users/taylan/Development/Horizon/sequence.js/packages/wallet/primitives
3
+ > @0xsequence/wallet-primitives@3.0.0-beta.3 build /Users/taylan/Development/Horizon/sequence.js/packages/wallet/primitives
4
4
  > tsc
5
5
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @0xsequence/wallet-primitives
2
2
 
3
+ ## 3.0.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 3.0.0-beta.3 with fixes
8
+
9
+ ## 3.0.0-beta.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 3.0.0-beta.2 with identity instrument updates
14
+
3
15
  ## 3.0.0-beta.1
4
16
 
5
17
  ### Patch Changes
package/dist/erc-6492.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AbiFunction, AbiParameters, Bytes, Hex } from 'ox';
2
- import { WrappedSignature } from 'ox/erc6492';
2
+ import { SignatureErc6492 } from 'ox/erc6492';
3
3
  import { DEPLOY } from './constants.js';
4
4
  const EIP_6492_OFFCHAIN_DEPLOY_CODE = '0x608060405234801561001057600080fd5b5060405161124a38038061124a83398101604081905261002f91610124565b600060405161003d906100dd565b604051809103906000f080158015610059573d6000803e3d6000fd5b5090506000816001600160a01b0316638f0684308686866040518463ffffffff1660e01b815260040161008e939291906101fb565b6020604051808303816000875af11580156100ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100d19190610244565b9050806000526001601ff35b610fdc8061026e83390190565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561011b578181015183820152602001610103565b50506000910152565b60008060006060848603121561013957600080fd5b83516001600160a01b038116811461015057600080fd5b6020850151604086015191945092506001600160401b038082111561017457600080fd5b818601915086601f83011261018857600080fd5b81518181111561019a5761019a6100ea565b604051601f8201601f19908116603f011681019083821181831017156101c2576101c26100ea565b816040528281528960208487010111156101db57600080fd5b6101ec836020830160208801610100565b80955050505050509250925092565b60018060a01b0384168152826020820152606060408201526000825180606084015261022e816080850160208701610100565b601f01601f191691909101608001949350505050565b60006020828403121561025657600080fd5b8151801515811461026657600080fd5b939250505056fe608060405234801561001057600080fd5b50610fbc806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806376be4cea1161005057806376be4cea146100a65780638f068430146100b957806398ef1ed8146100cc57600080fd5b80631c6453271461006c5780633d787b6314610093575b600080fd5b61007f61007a366004610ad4565b6100df565b604051901515815260200160405180910390f35b61007f6100a1366004610ad4565b61023d565b61007f6100b4366004610b3e565b61031e565b61007f6100c7366004610ad4565b6108e1565b61007f6100da366004610ad4565b61096e565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea9061012890889088908890889088908190600401610bc3565b6020604051808303816000875af1925050508015610181575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261017e91810190610c45565b60015b610232573d8080156101af576040519150601f19603f3d011682016040523d82523d6000602084013e6101b4565b606091505b508051600181900361022757816000815181106101d3576101d3610c69565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f0100000000000000000000000000000000000000000000000000000000000000149250610235915050565b600092505050610235565b90505b949350505050565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea906102879088908890889088906001908990600401610bc3565b6020604051808303816000875af19250505080156102e0575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526102dd91810190610c45565b60015b610232573d80801561030e576040519150601f19603f3d011682016040523d82523d6000602084013e610313565b606091505b506000915050610235565b600073ffffffffffffffffffffffffffffffffffffffff87163b6060827f64926492649264926492649264926492649264926492649264926492649264928888610369602082610c98565b610375928b9290610cd8565b61037e91610d02565b1490508015610484576000606089828a610399602082610c98565b926103a693929190610cd8565b8101906103b39190610e18565b955090925090508415806103c45750865b1561047d576000808373ffffffffffffffffffffffffffffffffffffffff16836040516103f19190610eb2565b6000604051808303816000865af19150503d806000811461042e576040519150601f19603f3d011682016040523d82523d6000602084013e610433565b606091505b50915091508161047a57806040517f9d0d6e2d0000000000000000000000000000000000000000000000000000000081526004016104719190610f18565b60405180910390fd5b50505b50506104be565b87878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509294505050505b80806104ca5750600083115b156106bb576040517f1626ba7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b1690631626ba7e90610523908c908690600401610f2b565b602060405180830381865afa92505050801561057a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261057791810190610f44565b60015b61060f573d8080156105a8576040519150601f19603f3d011682016040523d82523d6000602084013e6105ad565b606091505b50851580156105bc5750600084115b156105db576105d08b8b8b8b8b600161031e565b9450505050506108d7565b806040517f6f2a95990000000000000000000000000000000000000000000000000000000081526004016104719190610f18565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f1626ba7e000000000000000000000000000000000000000000000000000000001480158161065f575086155b801561066b5750600085115b1561068b5761067f8c8c8c8c8c600161031e565b955050505050506108d7565b841580156106965750825b80156106a0575087155b156106af57806000526001601ffd5b94506108d79350505050565b6041871461074b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610471565b600061075a6020828a8c610cd8565b61076391610d02565b90506000610775604060208b8d610cd8565b61077e91610d02565b905060008a8a604081811061079557610795610c69565b919091013560f81c915050601b81148015906107b557508060ff16601c14155b15610842576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f5369676e617475726556616c696461746f723a20696e76616c6964207369676e60448201527f617475726520762076616c7565000000000000000000000000000000000000006064820152608401610471565b6040805160008152602081018083528e905260ff831691810191909152606081018490526080810183905273ffffffffffffffffffffffffffffffffffffffff8e169060019060a0016020604051602081039080840390855afa1580156108ad573d6000803e3d6000fd5b5050506020604051035173ffffffffffffffffffffffffffffffffffffffff161496505050505050505b9695505050505050565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea9061092b9088908890889088906001908990600401610bc3565b6020604051808303816000875af115801561094a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102329190610c45565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea906109b790889088908890889088908190600401610bc3565b6020604051808303816000875af1925050508015610a10575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252610a0d91810190610c45565b60015b610232573d808015610a3e576040519150601f19603f3d011682016040523d82523d6000602084013e610a43565b606091505b5080516001819003610a6257816000815181106101d3576101d3610c69565b8082fd5b73ffffffffffffffffffffffffffffffffffffffff81168114610a8857600080fd5b50565b60008083601f840112610a9d57600080fd5b50813567ffffffffffffffff811115610ab557600080fd5b602083019150836020828501011115610acd57600080fd5b9250929050565b60008060008060608587031215610aea57600080fd5b8435610af581610a66565b935060208501359250604085013567ffffffffffffffff811115610b1857600080fd5b610b2487828801610a8b565b95989497509550505050565b8015158114610a8857600080fd5b60008060008060008060a08789031215610b5757600080fd5b8635610b6281610a66565b955060208701359450604087013567ffffffffffffffff811115610b8557600080fd5b610b9189828a01610a8b565b9095509350506060870135610ba581610b30565b91506080870135610bb581610b30565b809150509295509295509295565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a060408201528360a0820152838560c0830137600060c085830181019190915292151560608201529015156080820152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909101019392505050565b600060208284031215610c5757600080fd5b8151610c6281610b30565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b81810381811115610cd2577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b60008085851115610ce857600080fd5b83861115610cf557600080fd5b5050820193919092039150565b80356020831015610cd2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602084900360031b1b1692915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112610d7e57600080fd5b813567ffffffffffffffff80821115610d9957610d99610d3e565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715610ddf57610ddf610d3e565b81604052838152866020858801011115610df857600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600060608486031215610e2d57600080fd5b8335610e3881610a66565b9250602084013567ffffffffffffffff80821115610e5557600080fd5b610e6187838801610d6d565b93506040860135915080821115610e7757600080fd5b50610e8486828701610d6d565b9150509250925092565b60005b83811015610ea9578181015183820152602001610e91565b50506000910152565b60008251610ec4818460208701610e8e565b9190910192915050565b60008151808452610ee6816020860160208601610e8e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610c626020830184610ece565b8281526040602082015260006102356040830184610ece565b600060208284031215610f5657600080fd5b81517fffffffff0000000000000000000000000000000000000000000000000000000081168114610c6257600080fdfea26469706673582212201a72aed4b15ffb05b6502997a9bb655992e06590bd26b336dfbb153d7ff6f34b64736f6c63430008120033';
5
5
  export function deploy(deployHash, context) {
@@ -12,7 +12,7 @@ export function deploy(deployHash, context) {
12
12
  }
13
13
  }
14
14
  export function wrap(signature, { to, data }) {
15
- const encoded = Hex.concat(AbiParameters.encode([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], [to, Hex.from(data), Hex.from(signature)]), WrappedSignature.magicBytes);
15
+ const encoded = Hex.concat(AbiParameters.encode([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], [to, Hex.from(data), Hex.from(signature)]), SignatureErc6492.magicBytes);
16
16
  switch (typeof signature) {
17
17
  case 'object':
18
18
  return Hex.toBytes(encoded);
@@ -23,18 +23,18 @@ export function wrap(signature, { to, data }) {
23
23
  export function decode(signature) {
24
24
  switch (typeof signature) {
25
25
  case 'object':
26
- if (Bytes.toHex(signature.subarray(-WrappedSignature.magicBytes.slice(2).length / 2)) ===
27
- WrappedSignature.magicBytes) {
28
- const [to, data, decoded] = AbiParameters.decode([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], signature.subarray(0, -WrappedSignature.magicBytes.slice(2).length / 2));
26
+ if (Bytes.toHex(signature.subarray(-SignatureErc6492.magicBytes.slice(2).length / 2)) ===
27
+ SignatureErc6492.magicBytes) {
28
+ const [to, data, decoded] = AbiParameters.decode([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], signature.subarray(0, -SignatureErc6492.magicBytes.slice(2).length / 2));
29
29
  return { signature: Hex.toBytes(decoded), erc6492: { to, data: Hex.toBytes(data) } };
30
30
  }
31
31
  else {
32
32
  return { signature };
33
33
  }
34
34
  case 'string':
35
- if (signature.endsWith(WrappedSignature.magicBytes.slice(2))) {
35
+ if (signature.endsWith(SignatureErc6492.magicBytes.slice(2))) {
36
36
  try {
37
- const [to, data, decoded] = AbiParameters.decode([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], signature.slice(0, -WrappedSignature.magicBytes.slice(2).length));
37
+ const [to, data, decoded] = AbiParameters.decode([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], signature.slice(0, -SignatureErc6492.magicBytes.slice(2).length));
38
38
  return { signature: decoded, erc6492: { to, data: data } };
39
39
  }
40
40
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/wallet-primitives",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,13 +14,13 @@
14
14
  }
15
15
  },
16
16
  "devDependencies": {
17
- "@vitest/coverage-v8": "^3.2.4",
18
- "typescript": "^5.8.3",
19
- "vitest": "^3.2.1",
20
- "@repo/typescript-config": "^0.0.0"
17
+ "@vitest/coverage-v8": "^4.0.14",
18
+ "typescript": "^5.9.3",
19
+ "vitest": "^4.0.14",
20
+ "@repo/typescript-config": "^0.0.1-beta.0"
21
21
  },
22
22
  "dependencies": {
23
- "ox": "^0.7.2"
23
+ "ox": "^0.9.17"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsc",
package/src/erc-6492.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AbiFunction, AbiParameters, Address, Bytes, Hex, Provider } from 'ox'
2
- import { WrappedSignature } from 'ox/erc6492'
2
+ import { SignatureErc6492 } from 'ox/erc6492'
3
3
  import { DEPLOY } from './constants.js'
4
4
  import { Context } from './context.js'
5
5
 
@@ -29,7 +29,7 @@ export function wrap<T extends Bytes.Bytes | Hex.Hex>(
29
29
  [{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
30
30
  [to, Hex.from(data), Hex.from(signature)],
31
31
  ),
32
- WrappedSignature.magicBytes,
32
+ SignatureErc6492.magicBytes,
33
33
  )
34
34
 
35
35
  switch (typeof signature) {
@@ -46,12 +46,12 @@ export function decode<T extends Bytes.Bytes | Hex.Hex>(
46
46
  switch (typeof signature) {
47
47
  case 'object':
48
48
  if (
49
- Bytes.toHex(signature.subarray(-WrappedSignature.magicBytes.slice(2).length / 2)) ===
50
- WrappedSignature.magicBytes
49
+ Bytes.toHex(signature.subarray(-SignatureErc6492.magicBytes.slice(2).length / 2)) ===
50
+ SignatureErc6492.magicBytes
51
51
  ) {
52
52
  const [to, data, decoded] = AbiParameters.decode(
53
53
  [{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
54
- signature.subarray(0, -WrappedSignature.magicBytes.slice(2).length / 2),
54
+ signature.subarray(0, -SignatureErc6492.magicBytes.slice(2).length / 2),
55
55
  )
56
56
  return { signature: Hex.toBytes(decoded) as T, erc6492: { to, data: Hex.toBytes(data) as T } }
57
57
  } else {
@@ -59,11 +59,11 @@ export function decode<T extends Bytes.Bytes | Hex.Hex>(
59
59
  }
60
60
 
61
61
  case 'string':
62
- if (signature.endsWith(WrappedSignature.magicBytes.slice(2))) {
62
+ if (signature.endsWith(SignatureErc6492.magicBytes.slice(2))) {
63
63
  try {
64
64
  const [to, data, decoded] = AbiParameters.decode(
65
65
  [{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
66
- signature.slice(0, -WrappedSignature.magicBytes.slice(2).length) as Hex.Hex,
66
+ signature.slice(0, -SignatureErc6492.magicBytes.slice(2).length) as Hex.Hex,
67
67
  )
68
68
  return { signature: decoded as T, erc6492: { to, data: data as T } }
69
69
  } catch {
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it, vi } from 'vitest'
2
2
  import { Address, Bytes, Hex, Provider } from 'ox'
3
- import { WrappedSignature } from 'ox/erc6492'
3
+ import { SignatureErc6492 } from 'ox/erc6492'
4
4
 
5
5
  import { deploy, wrap, decode, isValid } from '../src/erc-6492.js'
6
6
  import { Context } from '../src/context.js'
@@ -82,7 +82,7 @@ describe('ERC-6492', () => {
82
82
  expect(result.startsWith('0x')).toBe(true)
83
83
 
84
84
  // Should end with the magic bytes
85
- expect(result.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
85
+ expect(result.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)
86
86
 
87
87
  // Should contain the original signature data somewhere
88
88
  expect(result.length).toBeGreaterThan(testSignature.length)
@@ -96,7 +96,7 @@ describe('ERC-6492', () => {
96
96
 
97
97
  // Convert to hex to check magic bytes
98
98
  const resultHex = Bytes.toHex(result)
99
- expect(resultHex.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
99
+ expect(resultHex.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)
100
100
  })
101
101
 
102
102
  it('should return same type as input signature', () => {
@@ -133,7 +133,7 @@ describe('ERC-6492', () => {
133
133
  // The wrapped signature should contain encoded: address, bytes (data), bytes (signature)
134
134
  expect(result.length).toBeGreaterThan(testSignature.length + deployData.data.length)
135
135
  expect(result).toContain(testAddress.slice(2)) // Address without 0x
136
- expect(result.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
136
+ expect(result.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)
137
137
  })
138
138
  })
139
139
 
@@ -209,7 +209,7 @@ describe('ERC-6492', () => {
209
209
 
210
210
  it('should handle malformed wrapped signature gracefully', () => {
211
211
  // Create a signature that ends with magic bytes but has invalid encoding
212
- const malformedSig = ('0x1234' + WrappedSignature.magicBytes.slice(2)) as Hex.Hex
212
+ const malformedSig = ('0x1234' + SignatureErc6492.magicBytes.slice(2)) as Hex.Hex
213
213
  const result = decode(malformedSig)
214
214
 
215
215
  // Should return original signature when decoding fails
@@ -391,7 +391,7 @@ describe('ERC-6492', () => {
391
391
 
392
392
  // 2. Wrap signature with deploy data
393
393
  const wrappedSig = wrap(testSignature, deployCall)
394
- expect(wrappedSig.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
394
+ expect(wrappedSig.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)
395
395
 
396
396
  // 3. Decode wrapped signature
397
397
  const decoded = decode(wrappedSig)
@@ -457,7 +457,7 @@ describe('ERC-6492', () => {
457
457
 
458
458
  it('should handle signatures that accidentally contain magic bytes', () => {
459
459
  // Create a signature that contains the magic bytes but isn't wrapped
460
- const magicInSignature = (testSignature + WrappedSignature.magicBytes.slice(2) + '1234') as Hex.Hex
460
+ const magicInSignature = (testSignature + SignatureErc6492.magicBytes.slice(2) + '1234') as Hex.Hex
461
461
  const result = decode(magicInSignature)
462
462
 
463
463
  // Should try to decode, but if it fails, should return original