viem 2.56.6 → 2.56.7
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 +14 -0
- package/_cjs/chains/definitions/eCanna.js +23 -0
- package/_cjs/chains/definitions/eCanna.js.map +1 -0
- package/_cjs/chains/definitions/eCannaTestnet.js +24 -0
- package/_cjs/chains/definitions/eCannaTestnet.js.map +1 -0
- package/_cjs/chains/definitions/robinhood.js +5 -1
- package/_cjs/chains/definitions/robinhood.js.map +1 -1
- package/_cjs/chains/definitions/zagros.js +33 -0
- package/_cjs/chains/definitions/zagros.js.map +1 -0
- package/_cjs/chains/index.js +18 -12
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Account.js +21 -30
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Multisig.js +14 -107
- package/_cjs/tempo/Multisig.js.map +1 -1
- package/_cjs/tempo/Transaction.js +5 -2
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/actions/accessKey.js +2 -1
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +3 -31
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/multisig/Config.js +8 -4
- package/_cjs/tempo/multisig/Config.js.map +1 -1
- package/_cjs/tempo/multisig/Signature.js +11 -0
- package/_cjs/tempo/multisig/Signature.js.map +1 -0
- package/_cjs/tokens/definitions/cirbtc.js +1 -0
- package/_cjs/tokens/definitions/cirbtc.js.map +1 -1
- package/_cjs/tokens/definitions/eurc.js +1 -0
- package/_cjs/tokens/definitions/eurc.js.map +1 -1
- package/_esm/chains/definitions/eCanna.js +20 -0
- package/_esm/chains/definitions/eCanna.js.map +1 -0
- package/_esm/chains/definitions/eCannaTestnet.js +21 -0
- package/_esm/chains/definitions/eCannaTestnet.js.map +1 -0
- package/_esm/chains/definitions/robinhood.js +5 -1
- package/_esm/chains/definitions/robinhood.js.map +1 -1
- package/_esm/chains/definitions/zagros.js +30 -0
- package/_esm/chains/definitions/zagros.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Account.js +21 -30
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Addresses.js +2 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Multisig.js +15 -111
- package/_esm/tempo/Multisig.js.map +1 -1
- package/_esm/tempo/Transaction.js +5 -2
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/actions/accessKey.js +2 -1
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/chainConfig.js +3 -31
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/multisig/Config.js +10 -5
- package/_esm/tempo/multisig/Config.js.map +1 -1
- package/_esm/tempo/multisig/Signature.js +9 -0
- package/_esm/tempo/multisig/Signature.js.map +1 -0
- package/_esm/tokens/definitions/cirbtc.js +1 -0
- package/_esm/tokens/definitions/cirbtc.js.map +1 -1
- package/_esm/tokens/definitions/eurc.js +1 -0
- package/_esm/tokens/definitions/eurc.js.map +1 -1
- package/_types/chains/definitions/eCanna.d.ts +51 -0
- package/_types/chains/definitions/eCanna.d.ts.map +1 -0
- package/_types/chains/definitions/eCannaTestnet.d.ts +51 -0
- package/_types/chains/definitions/eCannaTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/robinhood.d.ts +2 -1
- package/_types/chains/definitions/robinhood.d.ts.map +1 -1
- package/_types/chains/definitions/tempo.d.ts +2 -4
- package/_types/chains/definitions/tempo.d.ts.map +1 -1
- package/_types/chains/definitions/tempoDevnet.d.ts +2 -4
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +2 -4
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoModerato.d.ts +2 -4
- package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
- package/_types/chains/definitions/zagros.d.ts +50 -0
- package/_types/chains/definitions/zagros.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Account.d.ts +9 -3
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +2 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Multisig.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +16 -7
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/actions/accessKey.d.ts +2 -2
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +1 -3
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/multisig/Config.d.ts.map +1 -1
- package/_types/tempo/multisig/Signature.d.ts +4 -0
- package/_types/tempo/multisig/Signature.d.ts.map +1 -0
- package/_types/tokens/definitions/cirbtc.d.ts +1 -0
- package/_types/tokens/definitions/cirbtc.d.ts.map +1 -1
- package/_types/tokens/definitions/eurc.d.ts +1 -0
- package/_types/tokens/definitions/eurc.d.ts.map +1 -1
- package/_types/tokens/sets.d.ts +2 -0
- package/_types/tokens/sets.d.ts.map +1 -1
- package/chains/definitions/eCanna.ts +20 -0
- package/chains/definitions/eCannaTestnet.ts +21 -0
- package/chains/definitions/robinhood.ts +5 -1
- package/chains/definitions/zagros.ts +30 -0
- package/chains/index.ts +3 -0
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Account.ts +32 -43
- package/tempo/Addresses.ts +3 -0
- package/tempo/Multisig.ts +19 -132
- package/tempo/Transaction.ts +24 -9
- package/tempo/actions/accessKey.ts +4 -3
- package/tempo/chainConfig.ts +3 -42
- package/tempo/multisig/Config.ts +15 -5
- package/tempo/multisig/Signature.ts +11 -0
- package/tokens/definitions/cirbtc.ts +1 -0
- package/tokens/definitions/eurc.ts +1 -0
package/tempo/Transaction.ts
CHANGED
|
@@ -42,7 +42,8 @@ import {
|
|
|
42
42
|
parseTransaction as viem_parseTransaction,
|
|
43
43
|
} from '../utils/transaction/parseTransaction.js'
|
|
44
44
|
import { serializeTransaction as viem_serializeTransaction } from '../utils/transaction/serializeTransaction.js'
|
|
45
|
-
import type {
|
|
45
|
+
import type { RootAccount } from './Account.js'
|
|
46
|
+
import { parseApproval } from './multisig/Signature.js'
|
|
46
47
|
|
|
47
48
|
export type Transaction<
|
|
48
49
|
bigintType = bigint,
|
|
@@ -135,7 +136,7 @@ export type TransactionRequestTempo<
|
|
|
135
136
|
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
136
137
|
multisigSimulation?: MultisigSimulation.Spec | undefined
|
|
137
138
|
nonceKey?: 'expiring' | quantity | undefined
|
|
138
|
-
owner?:
|
|
139
|
+
owner?: RootAccount | undefined
|
|
139
140
|
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
140
141
|
validBefore?: index | undefined
|
|
141
142
|
validAfter?: index | undefined
|
|
@@ -155,17 +156,30 @@ export type TransactionSerializableTempo<
|
|
|
155
156
|
chainId: number
|
|
156
157
|
feeToken?: Address | bigint | undefined
|
|
157
158
|
feePayerSignature?: viem_Signature | null | undefined
|
|
158
|
-
from?: Address | undefined
|
|
159
159
|
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
160
|
-
multisigSimulation?: MultisigSimulation.Spec | undefined
|
|
161
160
|
nonceKey?: quantity | undefined
|
|
162
|
-
owner?:
|
|
161
|
+
owner?: RootAccount | undefined
|
|
163
162
|
signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined
|
|
164
|
-
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
165
163
|
validBefore?: index | undefined
|
|
166
164
|
validAfter?: index | undefined
|
|
167
165
|
type?: 'tempo' | undefined
|
|
168
|
-
}
|
|
166
|
+
} & (
|
|
167
|
+
| {
|
|
168
|
+
from: Address
|
|
169
|
+
multisigSimulation?: MultisigSimulation.Spec | undefined
|
|
170
|
+
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
171
|
+
}
|
|
172
|
+
| {
|
|
173
|
+
from?: Address | undefined
|
|
174
|
+
multisigSimulation?: undefined
|
|
175
|
+
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
176
|
+
}
|
|
177
|
+
| {
|
|
178
|
+
from?: Address | undefined
|
|
179
|
+
multisigSimulation?: MultisigSimulation.Spec | undefined
|
|
180
|
+
signatures?: undefined
|
|
181
|
+
}
|
|
182
|
+
)
|
|
169
183
|
|
|
170
184
|
export type TransactionSerialized<
|
|
171
185
|
type extends TransactionType = TransactionType,
|
|
@@ -381,10 +395,11 @@ async function serializeTempo(
|
|
|
381
395
|
|
|
382
396
|
const payload = TxTempo.getSignPayload(TxTempo.from(transaction_sender_ox))
|
|
383
397
|
const signatures = transaction.signatures.map((approval) =>
|
|
384
|
-
|
|
398
|
+
parseApproval(approval),
|
|
385
399
|
)
|
|
386
400
|
const config = MultisigConfig.from(multisigSimulation.config)
|
|
387
|
-
const account =
|
|
401
|
+
const account = transaction.from
|
|
402
|
+
if (!account) throw new Error('A multisig sender is required for signing.')
|
|
388
403
|
const sorted = SignatureEnvelope.sortMultisigApprovals({
|
|
389
404
|
account,
|
|
390
405
|
config,
|
|
@@ -48,6 +48,7 @@ import type {
|
|
|
48
48
|
WriteParameters,
|
|
49
49
|
} from '../internal/types.js'
|
|
50
50
|
import { defineCall } from '../internal/utils.js'
|
|
51
|
+
import { parseApproval } from '../multisig/Signature.js'
|
|
51
52
|
import type { TransactionReceipt } from '../Transaction.js'
|
|
52
53
|
import { getConfig } from './multisig.js'
|
|
53
54
|
|
|
@@ -1240,7 +1241,7 @@ export async function signAuthorization<
|
|
|
1240
1241
|
signature: SignatureEnvelope.from({
|
|
1241
1242
|
account: account.address,
|
|
1242
1243
|
config,
|
|
1243
|
-
signatures: [
|
|
1244
|
+
signatures: [parseApproval(signature)],
|
|
1244
1245
|
}),
|
|
1245
1246
|
type,
|
|
1246
1247
|
...(witness ? { witness } : {}),
|
|
@@ -1323,7 +1324,7 @@ export namespace signAuthorization {
|
|
|
1323
1324
|
/** Multisig account being authorized. */
|
|
1324
1325
|
account: Address | MultisigAccount
|
|
1325
1326
|
/** Local owner that approves the authorization. */
|
|
1326
|
-
owner: RootAccount
|
|
1327
|
+
owner: RootAccount
|
|
1327
1328
|
}
|
|
1328
1329
|
|
|
1329
1330
|
/** Coordinated key authorization parameters. */
|
|
@@ -1333,7 +1334,7 @@ export namespace signAuthorization {
|
|
|
1333
1334
|
/** Stored multisig operation hash. */
|
|
1334
1335
|
hash: Hex
|
|
1335
1336
|
/** Local owner that approves the authorization. */
|
|
1336
|
-
owner: RootAccount
|
|
1337
|
+
owner: RootAccount
|
|
1337
1338
|
}
|
|
1338
1339
|
>
|
|
1339
1340
|
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -85,10 +85,7 @@ export const chainConfig = {
|
|
|
85
85
|
throw new Error(
|
|
86
86
|
'A local owner account is required to approve a stored multisig transaction.',
|
|
87
87
|
)
|
|
88
|
-
if (
|
|
89
|
-
request.owner.source !== 'root' &&
|
|
90
|
-
request.owner.source !== 'multisig'
|
|
91
|
-
)
|
|
88
|
+
if (request.owner.source !== 'root')
|
|
92
89
|
throw new Error(
|
|
93
90
|
'A Tempo owner account is required to approve a stored multisig transaction.',
|
|
94
91
|
)
|
|
@@ -125,7 +122,6 @@ export const chainConfig = {
|
|
|
125
122
|
account: request.account,
|
|
126
123
|
from: operation.account,
|
|
127
124
|
multisigSimulation: getMultisigSimulation({
|
|
128
|
-
account: operation.account,
|
|
129
125
|
config: operation.config,
|
|
130
126
|
local: request.account,
|
|
131
127
|
}),
|
|
@@ -168,11 +164,7 @@ export const chainConfig = {
|
|
|
168
164
|
throw new Error(
|
|
169
165
|
'A local owner account is required to approve a multisig transaction.',
|
|
170
166
|
)
|
|
171
|
-
if (
|
|
172
|
-
request.owner &&
|
|
173
|
-
request.owner.source !== 'root' &&
|
|
174
|
-
request.owner.source !== 'multisig'
|
|
175
|
-
)
|
|
167
|
+
if (request.owner && request.owner.source !== 'root')
|
|
176
168
|
throw new Error(
|
|
177
169
|
'A Tempo owner account is required to approve a multisig transaction.',
|
|
178
170
|
)
|
|
@@ -206,7 +198,6 @@ export const chainConfig = {
|
|
|
206
198
|
)
|
|
207
199
|
request.from = account
|
|
208
200
|
request.multisigSimulation = getMultisigSimulation({
|
|
209
|
-
account,
|
|
210
201
|
config,
|
|
211
202
|
local,
|
|
212
203
|
})
|
|
@@ -409,48 +400,18 @@ export type ChainConfig = typeof chainConfig
|
|
|
409
400
|
|
|
410
401
|
/** Builds a bounded multisig spec for gas simulation. */
|
|
411
402
|
function getMultisigSimulation(options: {
|
|
412
|
-
account: Address
|
|
413
403
|
config: MultisigConfig.Config
|
|
414
404
|
local?: MultisigAccount | undefined
|
|
415
405
|
}): MultisigSimulation.Spec {
|
|
416
|
-
const {
|
|
406
|
+
const { config, local } = options
|
|
417
407
|
return {
|
|
418
|
-
account,
|
|
419
408
|
approvals: selectOwners(config).map((owner) => {
|
|
420
409
|
const localOwner = local?.owners.find((account) =>
|
|
421
410
|
isAddressEqual(account.address, owner.owner),
|
|
422
411
|
)
|
|
423
|
-
if (localOwner?.source === 'multisig') {
|
|
424
|
-
const nested = localOwner as MultisigAccount
|
|
425
|
-
if (!nested.config)
|
|
426
|
-
throw new Error(
|
|
427
|
-
'A nested multisig config is required for gas estimation.',
|
|
428
|
-
)
|
|
429
|
-
return {
|
|
430
|
-
type: 'multisig',
|
|
431
|
-
spec: {
|
|
432
|
-
account: nested.address,
|
|
433
|
-
approvals: selectOwners(nested.config).map((owner) => {
|
|
434
|
-
const nestedOwner = nested.owners.find((account) =>
|
|
435
|
-
isAddressEqual(account.address, owner.owner),
|
|
436
|
-
)
|
|
437
|
-
if (nestedOwner?.source === 'multisig')
|
|
438
|
-
throw new Error(
|
|
439
|
-
'Multisig simulation nesting exceeds depth two.',
|
|
440
|
-
)
|
|
441
|
-
return {
|
|
442
|
-
...getSimulationKey(nestedOwner),
|
|
443
|
-
owner: owner.owner,
|
|
444
|
-
}
|
|
445
|
-
}),
|
|
446
|
-
config: nested.config,
|
|
447
|
-
},
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
412
|
return {
|
|
451
413
|
...getSimulationKey(localOwner),
|
|
452
414
|
owner: owner.owner,
|
|
453
|
-
type: 'primitive',
|
|
454
415
|
}
|
|
455
416
|
}),
|
|
456
417
|
config,
|
package/tempo/multisig/Config.ts
CHANGED
|
@@ -4,12 +4,13 @@ import type * as Hex from 'ox/Hex'
|
|
|
4
4
|
import * as Json from 'ox/Json'
|
|
5
5
|
import { MultisigConfig } from 'ox/tempo'
|
|
6
6
|
import { BaseError } from '../../errors/base.js'
|
|
7
|
+
import { nativeMultisigFactory } from '../Addresses.js'
|
|
7
8
|
import type * as Store from '../Store.js'
|
|
8
9
|
|
|
9
10
|
/** A valid 48-owner config is much smaller; 64 KiB bounds hostile store parsing work. */
|
|
10
11
|
const maxStoredValueLength = 65_536
|
|
11
12
|
|
|
12
|
-
/** Zero commitment used before an account
|
|
13
|
+
/** Zero commitment used before an account is initialized. */
|
|
13
14
|
const zeroCommitment = `0x${'00'.repeat(32)}` as const
|
|
14
15
|
|
|
15
16
|
/** Reads a cached multisig config. */
|
|
@@ -43,7 +44,14 @@ export async function write(
|
|
|
43
44
|
const { address, commitment } = options
|
|
44
45
|
const config = MultisigConfig.from(options.config)
|
|
45
46
|
assertKey({ address, commitment, config })
|
|
46
|
-
|
|
47
|
+
const value = serialize(config)
|
|
48
|
+
await store.setItem(key({ address, commitment }), value)
|
|
49
|
+
// Initialization commits the version-zero config without changing its version.
|
|
50
|
+
if (commitment.toLowerCase() === zeroCommitment)
|
|
51
|
+
await store.setItem(
|
|
52
|
+
key({ address, commitment: MultisigConfig.getCommitment(config) }),
|
|
53
|
+
value,
|
|
54
|
+
)
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
export declare namespace write {
|
|
@@ -69,11 +77,13 @@ function assertKey(options: {
|
|
|
69
77
|
throw new InvalidStoreValueError()
|
|
70
78
|
if (config.version === 0n) {
|
|
71
79
|
if (
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
!Address.isEqual(
|
|
81
|
+
MultisigConfig.getAddress(config, { factory: nativeMultisigFactory }),
|
|
82
|
+
address,
|
|
83
|
+
)
|
|
74
84
|
)
|
|
75
85
|
throw new InvalidStoreValueError()
|
|
76
|
-
return
|
|
86
|
+
if (commitment.toLowerCase() === zeroCommitment) return
|
|
77
87
|
}
|
|
78
88
|
if (
|
|
79
89
|
MultisigConfig.getCommitment(config).toLowerCase() !==
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SignatureEnvelope } from 'ox/tempo'
|
|
2
|
+
|
|
3
|
+
/** Parses a primitive multisig owner approval. */
|
|
4
|
+
export function parseApproval(
|
|
5
|
+
signature: SignatureEnvelope.Serialized,
|
|
6
|
+
): SignatureEnvelope.Primitive {
|
|
7
|
+
const approval = SignatureEnvelope.from(signature)
|
|
8
|
+
if (approval.type === 'multisig' || approval.type === 'keychain')
|
|
9
|
+
throw new Error('Multisig owners must use primitive signatures.')
|
|
10
|
+
return approval
|
|
11
|
+
}
|
|
@@ -11,6 +11,7 @@ import { defineToken } from '../defineToken.js'
|
|
|
11
11
|
export const cirbtc = /*#__PURE__*/ defineToken({
|
|
12
12
|
addresses: {
|
|
13
13
|
1: '0x72DFB2E44f59C5AD2bAFE84314E5b99a7cd5075E', // mainnet
|
|
14
|
+
5042: '0x171A4217b86A807A64eB94757Db6849fb4bDbAA0', // arc
|
|
14
15
|
5042002: '0xf0C4a4CE82A5746AbAAd9425360Ab04fbBA432BF', // arcTestnet
|
|
15
16
|
11155111: '0x3a3fe695F684Bf9b9e43CF43C2b895Ea5e392bB3', // sepolia
|
|
16
17
|
},
|
|
@@ -15,6 +15,7 @@ export const eurc = /*#__PURE__*/ defineToken({
|
|
|
15
15
|
338: '0x31f7538adb53cF16350e6B0c89d03D91b7D12c46', // cronosTestnet
|
|
16
16
|
480: '0x1C60ba0A0eD1019e8Eb035E6daF4155A5cE2380B', // worldchain
|
|
17
17
|
4801: '0xe479EcA5740Ac65d6E1823bea2f1C08Bc14e954F', // worldchainSepolia
|
|
18
|
+
5042: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1', // arc
|
|
18
19
|
8453: '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42', // base
|
|
19
20
|
43113: '0x5E44db7996c682E92a960b65AC713a54AD815c6B', // avalancheFuji
|
|
20
21
|
43114: '0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD', // avalanche
|