ox 0.14.55 → 0.14.57
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 +48 -0
- package/_cjs/tempo/{MultisigConfig.js → AccountConfig.js} +32 -9
- package/_cjs/tempo/AccountConfig.js.map +1 -0
- package/_cjs/tempo/{MultisigOperation.js → AccountOperation.js} +29 -29
- package/_cjs/tempo/AccountOperation.js.map +1 -0
- package/_cjs/tempo/{MultisigSimulation.js → AccountSimulation.js} +22 -13
- package/_cjs/tempo/AccountSimulation.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +10 -18
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +64 -64
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +15 -10
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/index.js +4 -4
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/{MultisigConfig.js → AccountConfig.js} +161 -64
- package/_esm/tempo/AccountConfig.js.map +1 -0
- package/_esm/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
- package/_esm/tempo/AccountOperation.js.map +1 -0
- package/_esm/tempo/{MultisigSimulation.js → AccountSimulation.js} +35 -25
- package/_esm/tempo/AccountSimulation.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +16 -19
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +71 -71
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +15 -10
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/index.js +50 -48
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +156 -66
- package/_types/tempo/AccountConfig.d.ts.map +1 -0
- package/_types/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
- package/_types/tempo/AccountOperation.d.ts.map +1 -0
- package/_types/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +25 -21
- package/_types/tempo/AccountSimulation.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +28 -23
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/RpcSchemaTempo.d.ts +13 -13
- package/_types/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +36 -33
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +11 -9
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +50 -48
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +31 -31
- package/tempo/AccountConfig/package.json +6 -0
- package/tempo/AccountConfig.test-d/package.json +6 -0
- package/tempo/AccountConfig.test-d.ts +72 -0
- package/tempo/AccountConfig.test.ts +642 -0
- package/tempo/{MultisigConfig.ts → AccountConfig.ts} +212 -75
- package/tempo/AccountOperation/package.json +6 -0
- package/tempo/AccountOperation.test-d/package.json +6 -0
- package/tempo/AccountOperation.test-d.ts +71 -0
- package/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +129 -129
- package/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
- package/tempo/AccountSimulation/package.json +6 -0
- package/tempo/AccountSimulation.test-d/package.json +6 -0
- package/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
- package/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +73 -29
- package/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +47 -35
- package/tempo/KeyAuthorization.test-d.ts +19 -29
- package/tempo/KeyAuthorization.test.ts +151 -74
- package/tempo/KeyAuthorization.ts +40 -61
- package/tempo/RpcSchemaTempo.test-d.ts +20 -20
- package/tempo/RpcSchemaTempo.ts +13 -13
- package/tempo/SignatureEnvelope.test-d.ts +7 -7
- package/tempo/SignatureEnvelope.test.ts +34 -34
- package/tempo/SignatureEnvelope.ts +107 -103
- package/tempo/Transaction.test.ts +4 -4
- package/tempo/TransactionRequest.test-d.ts +17 -8
- package/tempo/TransactionRequest.test.ts +31 -21
- package/tempo/TransactionRequest.ts +29 -20
- package/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
- package/tempo/index.ts +50 -48
- package/version.ts +1 -1
- package/_cjs/tempo/MultisigConfig.js.map +0 -1
- package/_cjs/tempo/MultisigOperation.js.map +0 -1
- package/_cjs/tempo/MultisigSimulation.js.map +0 -1
- package/_esm/tempo/MultisigConfig.js.map +0 -1
- package/_esm/tempo/MultisigOperation.js.map +0 -1
- package/_esm/tempo/MultisigSimulation.js.map +0 -1
- package/_types/tempo/MultisigConfig.d.ts.map +0 -1
- package/_types/tempo/MultisigOperation.d.ts.map +0 -1
- package/_types/tempo/MultisigSimulation.d.ts.map +0 -1
- package/tempo/MultisigConfig/package.json +0 -6
- package/tempo/MultisigConfig.test-d/package.json +0 -6
- package/tempo/MultisigConfig.test-d.ts +0 -52
- package/tempo/MultisigConfig.test.ts +0 -391
- package/tempo/MultisigOperation/package.json +0 -6
- package/tempo/MultisigOperation.test-d/package.json +0 -6
- package/tempo/MultisigOperation.test-d.ts +0 -71
- package/tempo/MultisigSimulation/package.json +0 -6
- package/tempo/MultisigSimulation.test-d/package.json +0 -6
|
@@ -29,7 +29,7 @@ import * as TempoAddress from './TempoAddress.js'
|
|
|
29
29
|
* - `chainId`: Chain ID for replay protection (0 = valid on any chain)
|
|
30
30
|
* - `expiry`: Unix timestamp when the key expires (undefined = never expires)
|
|
31
31
|
* - `limits`: Per-TIP-20 token spending limits (only applies to `transfer()` and `approve()` calls)
|
|
32
|
-
* - `type`: Key type (`secp256k1`, `p256`, `webAuthn`, or `
|
|
32
|
+
* - `type`: Key type (`secp256k1`, `p256`, `webAuthn`, or `configurable`)
|
|
33
33
|
*
|
|
34
34
|
* [Access Keys Specification](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#access-keys)
|
|
35
35
|
*/
|
|
@@ -77,39 +77,39 @@ export type KeyAuthorization<
|
|
|
77
77
|
witness?: Hex.Hex | undefined
|
|
78
78
|
} & (
|
|
79
79
|
| {
|
|
80
|
-
/**
|
|
80
|
+
/** Account address this authorization is bound to. Required when an admin access key signs the grant (TIP-1049). */
|
|
81
81
|
account?: addressType | undefined
|
|
82
82
|
/** Primitive key type. */
|
|
83
83
|
type: SignatureEnvelope.Type
|
|
84
84
|
}
|
|
85
85
|
| {
|
|
86
|
-
/** Required
|
|
87
|
-
account
|
|
88
|
-
/**
|
|
89
|
-
type: '
|
|
86
|
+
/** Account address this authorization is bound to. Required when an admin access key signs the grant (TIP-1049). */
|
|
87
|
+
account?: addressType | undefined
|
|
88
|
+
/** Configurable account key type. */
|
|
89
|
+
type: 'configurable'
|
|
90
90
|
}
|
|
91
91
|
) &
|
|
92
92
|
(signed extends true
|
|
93
93
|
? {
|
|
94
94
|
signature:
|
|
95
95
|
| SignatureEnvelope.Primitive<bigintType, numberType>
|
|
96
|
-
| SignatureEnvelope.
|
|
96
|
+
| SignatureEnvelope.Configurable<bigintType, numberType>
|
|
97
97
|
}
|
|
98
98
|
: {
|
|
99
99
|
signature?:
|
|
100
100
|
| SignatureEnvelope.Primitive<bigintType, numberType>
|
|
101
|
-
| SignatureEnvelope.
|
|
101
|
+
| SignatureEnvelope.Configurable<bigintType, numberType>
|
|
102
102
|
| undefined
|
|
103
103
|
})
|
|
104
104
|
|
|
105
105
|
/** Signature that can authorize an access key. */
|
|
106
106
|
export type Signature<bigintType = bigint, numberType = number> =
|
|
107
107
|
| SignatureEnvelope.Primitive<bigintType, numberType>
|
|
108
|
-
| SignatureEnvelope.
|
|
108
|
+
| SignatureEnvelope.Configurable<bigintType, numberType>
|
|
109
109
|
|
|
110
110
|
/** RPC-formatted signature that can authorize an access key. */
|
|
111
111
|
export type SignatureRpc =
|
|
112
|
-
| SignatureEnvelope.
|
|
112
|
+
| SignatureEnvelope.ConfigurableRpc
|
|
113
113
|
| SignatureEnvelope.PrimitiveRpc
|
|
114
114
|
|
|
115
115
|
/** Input type for a Key Authorization. */
|
|
@@ -146,10 +146,10 @@ export type Rpc = {
|
|
|
146
146
|
keyType: SignatureEnvelope.Type
|
|
147
147
|
}
|
|
148
148
|
| {
|
|
149
|
-
/**
|
|
150
|
-
account
|
|
151
|
-
/**
|
|
152
|
-
keyType: '
|
|
149
|
+
/** Optional account address binding (TIP-1049). */
|
|
150
|
+
account?: Address.Address | null | undefined
|
|
151
|
+
/** Configurable account key type, named `configurableAccount` by the node. */
|
|
152
|
+
keyType: 'configurableAccount'
|
|
153
153
|
}
|
|
154
154
|
)
|
|
155
155
|
|
|
@@ -180,9 +180,9 @@ export type Signed<
|
|
|
180
180
|
> = KeyAuthorization<true, bigintType, numberType, addressType>
|
|
181
181
|
|
|
182
182
|
type SignatureValue =
|
|
183
|
-
| SignatureEnvelope.from.
|
|
183
|
+
| SignatureEnvelope.from.ConfigurableFromConfig
|
|
184
184
|
| UnionPartialBy<SignatureEnvelope.Primitive, 'prehash' | 'type'>
|
|
185
|
-
| PartialBy<SignatureEnvelope.
|
|
185
|
+
| PartialBy<SignatureEnvelope.Configurable, 'type'>
|
|
186
186
|
| SignatureEnvelope.Secp256k1Flat
|
|
187
187
|
| SignatureEnvelope.Serialized
|
|
188
188
|
|
|
@@ -449,7 +449,6 @@ export function from<
|
|
|
449
449
|
options: from.Options<signature> = {},
|
|
450
450
|
): from.ReturnType<authorization, signature> {
|
|
451
451
|
if ('keyId' in authorization) return fromRpc(authorization as Rpc) as never
|
|
452
|
-
assertAccountBinding(authorization.type, authorization.account)
|
|
453
452
|
const auth = authorization as KeyAuthorization & {
|
|
454
453
|
limits?: readonly { token: TempoAddress.Address; limit: bigint }[]
|
|
455
454
|
scopes?: readonly {
|
|
@@ -508,11 +507,11 @@ export declare namespace from {
|
|
|
508
507
|
type Options<
|
|
509
508
|
signature extends SignatureValue | undefined = SignatureValue | undefined,
|
|
510
509
|
> = {
|
|
511
|
-
/** The primitive or
|
|
510
|
+
/** The primitive or configurable account signature to attach to the Key Authorization. */
|
|
512
511
|
signature?:
|
|
513
512
|
| signature
|
|
514
513
|
| SignatureEnvelope.Primitive
|
|
515
|
-
| SignatureEnvelope.
|
|
514
|
+
| SignatureEnvelope.Configurable
|
|
516
515
|
| undefined
|
|
517
516
|
}
|
|
518
517
|
|
|
@@ -535,10 +534,7 @@ export declare namespace from {
|
|
|
535
534
|
>
|
|
536
535
|
>
|
|
537
536
|
|
|
538
|
-
type ErrorType =
|
|
539
|
-
| InvalidSignatureTypeError
|
|
540
|
-
| MissingAccountError
|
|
541
|
-
| Errors.GlobalErrorType
|
|
537
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
542
538
|
}
|
|
543
539
|
|
|
544
540
|
/**
|
|
@@ -572,7 +568,7 @@ export function fromRpc(authorization: Rpc): Signed {
|
|
|
572
568
|
const witness = authorization.witness ?? undefined
|
|
573
569
|
const isAdmin = authorization.isAdmin ?? undefined
|
|
574
570
|
const account = authorization.account ?? undefined
|
|
575
|
-
|
|
571
|
+
const type = keyType === 'configurableAccount' ? 'configurable' : keyType
|
|
576
572
|
const signature = SignatureEnvelope.fromRpc(authorization.signature)
|
|
577
573
|
assertSignature(signature)
|
|
578
574
|
if (witness !== undefined) assertWitness(witness)
|
|
@@ -607,9 +603,7 @@ export function fromRpc(authorization: Rpc): Signed {
|
|
|
607
603
|
})),
|
|
608
604
|
...(scopes ? { scopes } : {}),
|
|
609
605
|
signature,
|
|
610
|
-
...(
|
|
611
|
-
? { account: account!, type: keyType }
|
|
612
|
-
: { type: keyType }),
|
|
606
|
+
...(type === 'configurable' ? { account: account!, type } : { type }),
|
|
613
607
|
...(witness !== undefined ? { witness } : {}),
|
|
614
608
|
...(account !== undefined ? { account } : {}),
|
|
615
609
|
...(isAdmin ? { isAdmin: true as const } : {}),
|
|
@@ -617,10 +611,7 @@ export function fromRpc(authorization: Rpc): Signed {
|
|
|
617
611
|
}
|
|
618
612
|
|
|
619
613
|
export declare namespace fromRpc {
|
|
620
|
-
type ErrorType =
|
|
621
|
-
| InvalidSignatureTypeError
|
|
622
|
-
| MissingAccountError
|
|
623
|
-
| Errors.GlobalErrorType
|
|
614
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
624
615
|
}
|
|
625
616
|
|
|
626
617
|
/**
|
|
@@ -683,7 +674,7 @@ export function fromTuple<const tuple extends Tuple>(
|
|
|
683
674
|
case '0x02':
|
|
684
675
|
return 'webAuthn'
|
|
685
676
|
case '0x03':
|
|
686
|
-
return '
|
|
677
|
+
return 'configurable'
|
|
687
678
|
default:
|
|
688
679
|
throw new Error(`Invalid key type: ${keyType_hex}`)
|
|
689
680
|
}
|
|
@@ -740,11 +731,10 @@ export function fromTuple<const tuple extends Tuple>(
|
|
|
740
731
|
const account = isAbsent(rawAccount)
|
|
741
732
|
? undefined
|
|
742
733
|
: (rawAccount as Address.Address)
|
|
743
|
-
assertAccountBinding(keyType, account)
|
|
744
734
|
const args: KeyAuthorization = {
|
|
745
735
|
address: keyId,
|
|
746
736
|
chainId: chainId === '0x' ? 0n : Hex.toBigInt(chainId),
|
|
747
|
-
...(keyType === '
|
|
737
|
+
...(keyType === 'configurable'
|
|
748
738
|
? { account: account!, type: keyType }
|
|
749
739
|
: { type: keyType }),
|
|
750
740
|
...(expiry !== undefined ? { expiry } : {}),
|
|
@@ -767,10 +757,7 @@ export declare namespace fromTuple {
|
|
|
767
757
|
KeyAuthorization<authorization extends Tuple<true> ? true : false>
|
|
768
758
|
>
|
|
769
759
|
|
|
770
|
-
type ErrorType =
|
|
771
|
-
| InvalidSignatureTypeError
|
|
772
|
-
| MissingAccountError
|
|
773
|
-
| Errors.GlobalErrorType
|
|
760
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
774
761
|
}
|
|
775
762
|
|
|
776
763
|
/**
|
|
@@ -962,7 +949,6 @@ export declare namespace serialize {
|
|
|
962
949
|
* @returns An RPC-formatted Key Authorization.
|
|
963
950
|
*/
|
|
964
951
|
export function toRpc(authorization: Signed): Rpc {
|
|
965
|
-
assertAccountBinding(authorization.type, authorization.account)
|
|
966
952
|
const {
|
|
967
953
|
address,
|
|
968
954
|
scopes,
|
|
@@ -1006,7 +992,9 @@ export function toRpc(authorization: Signed): Rpc {
|
|
|
1006
992
|
chainId: chainId === 0n ? '0x' : Hex.fromNumber(chainId),
|
|
1007
993
|
expiry: typeof expiry === 'number' ? Hex.fromNumber(expiry) : null,
|
|
1008
994
|
keyId: TempoAddress.resolve(address),
|
|
1009
|
-
...(type === '
|
|
995
|
+
...(type === 'configurable'
|
|
996
|
+
? { account, keyType: 'configurableAccount' as const }
|
|
997
|
+
: { keyType: type }),
|
|
1010
998
|
limits: limits?.map(({ token, limit, period }) => ({
|
|
1011
999
|
token,
|
|
1012
1000
|
limit: Hex.fromNumber(limit),
|
|
@@ -1014,7 +1002,7 @@ export function toRpc(authorization: Signed): Rpc {
|
|
|
1014
1002
|
})),
|
|
1015
1003
|
signature: SignatureEnvelope.toRpc(signature) as
|
|
1016
1004
|
| SignatureEnvelope.PrimitiveRpc
|
|
1017
|
-
| SignatureEnvelope.
|
|
1005
|
+
| SignatureEnvelope.ConfigurableRpc,
|
|
1018
1006
|
...(allowedCalls ? { allowedCalls } : {}),
|
|
1019
1007
|
...(witness !== undefined ? { witness } : {}),
|
|
1020
1008
|
...(isAdmin ? { isAdmin: true } : {}),
|
|
@@ -1023,10 +1011,7 @@ export function toRpc(authorization: Signed): Rpc {
|
|
|
1023
1011
|
}
|
|
1024
1012
|
|
|
1025
1013
|
export declare namespace toRpc {
|
|
1026
|
-
type ErrorType =
|
|
1027
|
-
| InvalidSignatureTypeError
|
|
1028
|
-
| MissingAccountError
|
|
1029
|
-
| Errors.GlobalErrorType
|
|
1014
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
1030
1015
|
}
|
|
1031
1016
|
|
|
1032
1017
|
/**
|
|
@@ -1063,7 +1048,6 @@ export declare namespace toRpc {
|
|
|
1063
1048
|
export function toTuple<const authorization extends KeyAuthorization>(
|
|
1064
1049
|
authorization: authorization,
|
|
1065
1050
|
): toTuple.ReturnType<authorization> {
|
|
1066
|
-
assertAccountBinding(authorization.type, authorization.account)
|
|
1067
1051
|
const {
|
|
1068
1052
|
address,
|
|
1069
1053
|
chainId,
|
|
@@ -1089,7 +1073,7 @@ export function toTuple<const authorization extends KeyAuthorization>(
|
|
|
1089
1073
|
return '0x01'
|
|
1090
1074
|
case 'webAuthn':
|
|
1091
1075
|
return '0x02'
|
|
1092
|
-
case '
|
|
1076
|
+
case 'configurable':
|
|
1093
1077
|
return '0x03'
|
|
1094
1078
|
default:
|
|
1095
1079
|
throw new Error(`Invalid key type: ${keyType}`)
|
|
@@ -1172,10 +1156,7 @@ export declare namespace toTuple {
|
|
|
1172
1156
|
type ReturnType<authorization extends KeyAuthorization = KeyAuthorization> =
|
|
1173
1157
|
Compute<Tuple<authorization extends KeyAuthorization<true> ? true : false>>
|
|
1174
1158
|
|
|
1175
|
-
type ErrorType =
|
|
1176
|
-
| InvalidSignatureTypeError
|
|
1177
|
-
| MissingAccountError
|
|
1178
|
-
| Errors.GlobalErrorType
|
|
1159
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
1179
1160
|
}
|
|
1180
1161
|
|
|
1181
1162
|
function bigintToHex(value: bigint): Hex.Hex {
|
|
@@ -1209,13 +1190,6 @@ function resolveSelector(
|
|
|
1209
1190
|
return AbiItem.getSelector(selector)
|
|
1210
1191
|
}
|
|
1211
1192
|
|
|
1212
|
-
function assertAccountBinding(
|
|
1213
|
-
type: KeyAuthorization['type'],
|
|
1214
|
-
account: TempoAddress.Address | null | undefined,
|
|
1215
|
-
): void {
|
|
1216
|
-
if (type === 'multisig' && account == null) throw new MissingAccountError()
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
1193
|
function assertWitness(witness: Hex.Hex): void {
|
|
1220
1194
|
if (Hex.size(witness) !== 32) throw new InvalidWitnessSizeError(witness)
|
|
1221
1195
|
}
|
|
@@ -1256,15 +1230,20 @@ export class InvalidSignatureTypeError extends Error {
|
|
|
1256
1230
|
override readonly name = 'KeyAuthorization.InvalidSignatureTypeError'
|
|
1257
1231
|
constructor(type: SignatureEnvelope.SignatureEnvelope['type']) {
|
|
1258
1232
|
super(
|
|
1259
|
-
`Signature type \`${type}\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, \`webAuthn\`, or \`
|
|
1233
|
+
`Signature type \`${type}\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, \`webAuthn\`, or \`configurable\`.`,
|
|
1260
1234
|
)
|
|
1261
1235
|
}
|
|
1262
1236
|
}
|
|
1263
1237
|
|
|
1264
|
-
/**
|
|
1238
|
+
/**
|
|
1239
|
+
* Thrown when a configurable account key grant omits its parent account binding.
|
|
1240
|
+
*
|
|
1241
|
+
* @deprecated No longer thrown. The Tempo node only requires `account` on grants
|
|
1242
|
+
* signed by an admin access key, which it checks against the transaction sender.
|
|
1243
|
+
*/
|
|
1265
1244
|
export class MissingAccountError extends Error {
|
|
1266
1245
|
override readonly name = 'KeyAuthorization.MissingAccountError'
|
|
1267
1246
|
constructor() {
|
|
1268
|
-
super('
|
|
1247
|
+
super('Configurable account key grants require a parent account binding.')
|
|
1269
1248
|
}
|
|
1270
1249
|
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
1
|
import type { Provider } from 'ox'
|
|
2
2
|
import type {
|
|
3
|
+
AccountConfig,
|
|
4
|
+
AccountOperation,
|
|
5
|
+
AccountSimulation,
|
|
3
6
|
KeyAuthorization,
|
|
4
|
-
MultisigConfig,
|
|
5
|
-
MultisigOperation,
|
|
6
|
-
MultisigSimulation,
|
|
7
7
|
RpcSchemaTempo,
|
|
8
8
|
} from 'ox/tempo'
|
|
9
9
|
import { expectTypeOf, test } from 'vitest'
|
|
10
10
|
import type * as Address from '../core/Address.js'
|
|
11
11
|
import type * as Hex from '../core/Hex.js'
|
|
12
12
|
|
|
13
|
-
declare const provider: Provider.Provider<{ schema: RpcSchemaTempo.
|
|
13
|
+
declare const provider: Provider.Provider<{ schema: RpcSchemaTempo.Account }>
|
|
14
14
|
declare const tempoProvider: Provider.Provider<{
|
|
15
15
|
schema: RpcSchemaTempo.Tempo
|
|
16
16
|
}>
|
|
17
17
|
declare const address: Address.Address
|
|
18
18
|
declare const hash: Hex.Hex
|
|
19
19
|
declare const keyAuthorization: KeyAuthorization.Rpc
|
|
20
|
-
declare const
|
|
20
|
+
declare const configurableAccountSimulation: AccountSimulation.Rpc
|
|
21
21
|
declare const serializedTransaction: Hex.Hex
|
|
22
22
|
declare const signature: Hex.Hex
|
|
23
23
|
|
|
24
|
-
test('
|
|
24
|
+
test('account provider methods', () => {
|
|
25
25
|
expectTypeOf(
|
|
26
26
|
provider.request({
|
|
27
|
-
method: '
|
|
27
|
+
method: 'account_approveRawTransaction',
|
|
28
28
|
params: [serializedTransaction],
|
|
29
29
|
}),
|
|
30
30
|
).resolves.toEqualTypeOf<Hex.Hex>()
|
|
31
31
|
|
|
32
32
|
expectTypeOf(
|
|
33
33
|
provider.request({
|
|
34
|
-
method: '
|
|
34
|
+
method: 'account_approveRawTransactionSync',
|
|
35
35
|
params: [serializedTransaction],
|
|
36
36
|
}),
|
|
37
|
-
).resolves.toEqualTypeOf<
|
|
37
|
+
).resolves.toEqualTypeOf<AccountOperation.TransactionRpc>()
|
|
38
38
|
|
|
39
39
|
provider.request({
|
|
40
|
-
method: '
|
|
40
|
+
method: 'account_approveRawTransactionSync',
|
|
41
41
|
params: [serializedTransaction, 30_000],
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
expectTypeOf(
|
|
45
45
|
provider.request({
|
|
46
|
-
method: '
|
|
46
|
+
method: 'account_approveKeyAuthorization',
|
|
47
47
|
params: [{ keyAuthorization }],
|
|
48
48
|
}),
|
|
49
|
-
).resolves.toEqualTypeOf<
|
|
49
|
+
).resolves.toEqualTypeOf<AccountOperation.KeyAuthorizationRpc>()
|
|
50
50
|
|
|
51
51
|
expectTypeOf(
|
|
52
52
|
provider.request({
|
|
53
|
-
method: '
|
|
53
|
+
method: 'account_approveKeyAuthorization',
|
|
54
54
|
params: [{ hash, signature }],
|
|
55
55
|
}),
|
|
56
|
-
).resolves.toEqualTypeOf<
|
|
56
|
+
).resolves.toEqualTypeOf<AccountOperation.KeyAuthorizationRpc>()
|
|
57
57
|
|
|
58
58
|
expectTypeOf(
|
|
59
59
|
provider.request({
|
|
60
|
-
method: '
|
|
60
|
+
method: 'account_getConfig',
|
|
61
61
|
params: [{ address }],
|
|
62
62
|
}),
|
|
63
|
-
).resolves.toEqualTypeOf<
|
|
63
|
+
).resolves.toEqualTypeOf<AccountConfig.Rpc | null>()
|
|
64
64
|
|
|
65
65
|
expectTypeOf(
|
|
66
66
|
provider.request({
|
|
67
|
-
method: '
|
|
67
|
+
method: 'account_getOperation',
|
|
68
68
|
params: [hash],
|
|
69
69
|
}),
|
|
70
|
-
).resolves.toEqualTypeOf<
|
|
70
|
+
).resolves.toEqualTypeOf<AccountOperation.Rpc | null>()
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
test('tempo simulation accepts
|
|
73
|
+
test('tempo simulation accepts account simulation specs', () => {
|
|
74
74
|
tempoProvider.request({
|
|
75
75
|
method: 'tempo_simulateV1',
|
|
76
76
|
params: [
|
|
@@ -79,7 +79,7 @@ test('tempo simulation accepts multisig specs', () => {
|
|
|
79
79
|
{
|
|
80
80
|
calls: [
|
|
81
81
|
{
|
|
82
|
-
|
|
82
|
+
configurableAccountSimulation,
|
|
83
83
|
},
|
|
84
84
|
],
|
|
85
85
|
},
|
package/tempo/RpcSchemaTempo.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type * as Hex from '../core/Hex.js'
|
|
|
5
5
|
import type * as Log from '../core/Log.js'
|
|
6
6
|
import type * as RpcSchema from '../core/RpcSchema.js'
|
|
7
7
|
import type * as StateOverrides from '../core/StateOverrides.js'
|
|
8
|
+
import type * as AccountConfig from './AccountConfig.js'
|
|
9
|
+
import type * as AccountOperation from './AccountOperation.js'
|
|
8
10
|
import type * as KeyAuthorization from './KeyAuthorization.js'
|
|
9
|
-
import type * as MultisigConfig from './MultisigConfig.js'
|
|
10
|
-
import type * as MultisigOperation from './MultisigOperation.js'
|
|
11
11
|
import type * as TransactionRequest from './TransactionRequest.js'
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -58,44 +58,44 @@ export type Tempo = RpcSchema.From<{
|
|
|
58
58
|
}
|
|
59
59
|
}>
|
|
60
60
|
|
|
61
|
-
/** Union of all JSON-RPC methods for the `
|
|
62
|
-
export type
|
|
61
|
+
/** Union of all JSON-RPC methods for the `account_` namespace. */
|
|
62
|
+
export type Account = RpcSchema.From<
|
|
63
63
|
| {
|
|
64
64
|
Request: {
|
|
65
|
-
method: '
|
|
65
|
+
method: 'account_approveRawTransaction'
|
|
66
66
|
params: [serializedTransaction: Hex.Hex]
|
|
67
67
|
}
|
|
68
68
|
ReturnType: Hex.Hex
|
|
69
69
|
}
|
|
70
70
|
| {
|
|
71
71
|
Request: {
|
|
72
|
-
method: '
|
|
72
|
+
method: 'account_approveRawTransactionSync'
|
|
73
73
|
params: [serializedTransaction: Hex.Hex, timeout?: number]
|
|
74
74
|
}
|
|
75
|
-
ReturnType:
|
|
75
|
+
ReturnType: AccountOperation.TransactionRpc
|
|
76
76
|
}
|
|
77
77
|
| {
|
|
78
78
|
Request: {
|
|
79
|
-
method: '
|
|
79
|
+
method: 'account_approveKeyAuthorization'
|
|
80
80
|
params: [
|
|
81
81
|
| { keyAuthorization: KeyAuthorization.Rpc }
|
|
82
82
|
| { hash: Hex.Hex; signature: Hex.Hex },
|
|
83
83
|
]
|
|
84
84
|
}
|
|
85
|
-
ReturnType:
|
|
85
|
+
ReturnType: AccountOperation.KeyAuthorizationRpc
|
|
86
86
|
}
|
|
87
87
|
| {
|
|
88
88
|
Request: {
|
|
89
|
-
method: '
|
|
89
|
+
method: 'account_getConfig'
|
|
90
90
|
params: [{ address: Address.Address }]
|
|
91
91
|
}
|
|
92
|
-
ReturnType:
|
|
92
|
+
ReturnType: AccountConfig.Rpc | null
|
|
93
93
|
}
|
|
94
94
|
| {
|
|
95
95
|
Request: {
|
|
96
|
-
method: '
|
|
96
|
+
method: 'account_getOperation'
|
|
97
97
|
params: [hash: Hex.Hex]
|
|
98
98
|
}
|
|
99
|
-
ReturnType:
|
|
99
|
+
ReturnType: AccountOperation.Rpc | null
|
|
100
100
|
}
|
|
101
101
|
>
|
|
@@ -15,24 +15,24 @@ const envelope = SignatureEnvelope.from({
|
|
|
15
15
|
signatures: [primitive],
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
test('preserves primitive and
|
|
18
|
+
test('preserves primitive and configurable RPC types', () => {
|
|
19
19
|
expectTypeOf(
|
|
20
20
|
SignatureEnvelope.toRpc(primitive),
|
|
21
21
|
).toEqualTypeOf<SignatureEnvelope.Secp256k1Rpc>()
|
|
22
22
|
expectTypeOf(SignatureEnvelope.toRpc(envelope)).toEqualTypeOf<Hex.Hex>()
|
|
23
23
|
expectTypeOf<
|
|
24
24
|
SignatureEnvelope.GetType<typeof envelope>
|
|
25
|
-
>().toEqualTypeOf<'
|
|
26
|
-
expectTypeOf(envelope).toMatchTypeOf<SignatureEnvelope.
|
|
25
|
+
>().toEqualTypeOf<'configurable'>()
|
|
26
|
+
expectTypeOf(envelope).toMatchTypeOf<SignatureEnvelope.Configurable>()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
test('requires config and primitive approvals', () => {
|
|
30
|
-
// @ts-expect-error Every
|
|
30
|
+
// @ts-expect-error Every configurable signature carries its current config.
|
|
31
31
|
SignatureEnvelope.from({ account: envelope.account, signatures: [primitive] })
|
|
32
|
-
// @ts-expect-error
|
|
32
|
+
// @ts-expect-error Configurable owners cannot recursively approve with configurable signatures.
|
|
33
33
|
SignatureEnvelope.from({ ...envelope, signatures: [envelope] })
|
|
34
|
-
// @ts-expect-error
|
|
35
|
-
const rpc: SignatureEnvelope.
|
|
34
|
+
// @ts-expect-error Configurable RPC signatures are hex-encoded RLP.
|
|
35
|
+
const rpc: SignatureEnvelope.ConfigurableRpc = {
|
|
36
36
|
account: envelope.account,
|
|
37
37
|
signatures: [],
|
|
38
38
|
}
|