@etherplay/delegation 0.0.0 → 0.1.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/README.md +135 -0
- package/contracts/Delegation.sol +465 -0
- package/contracts/IDelegation.sol +76 -0
- package/contracts/UsingDelegation.sol +163 -0
- package/contracts/utils/Payments.sol +63 -0
- package/contracts/utils/SignatureUtils.sol +107 -0
- package/contracts/utils/StringUtils.sol +66 -0
- package/dist/abi.d.ts +178 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +143 -0
- package/dist/abi.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/message.d.ts +37 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +52 -0
- package/dist/message.js.map +1 -0
- package/package.json +65 -2
- package/src/abi.ts +142 -0
- package/src/index.ts +13 -0
- package/src/message.ts +76 -0
- package/vectors.json +55 -0
package/dist/abi.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The delegation surface as an ABI, for a client that calls a contract it does not compile against.
|
|
3
|
+
*
|
|
4
|
+
* The same six functions {@link file://../contracts/IDelegation.sol} declares, plus the event and
|
|
5
|
+
* the errors an adopter of `UsingDelegation` actually exposes - the event because it IS the
|
|
6
|
+
* enumeration API (there is no onchain list of an account's delegates, so the set is reconstructed
|
|
7
|
+
* by replaying these logs), and the errors so a revert decodes into something an app can act on
|
|
8
|
+
* rather than a hex blob.
|
|
9
|
+
*
|
|
10
|
+
* Hand-written rather than generated, so it reads as the contract's surface and ships without a
|
|
11
|
+
* build artifact. Drift is caught instead of prevented: a test compiles the Solidity and asserts
|
|
12
|
+
* this is exactly its ABI, so adding a parameter on one side and not the other fails in CI.
|
|
13
|
+
*
|
|
14
|
+
* `as const`, so viem infers argument and return types from it.
|
|
15
|
+
*/
|
|
16
|
+
export const DELEGATION_ABI = [
|
|
17
|
+
{
|
|
18
|
+
type: 'function',
|
|
19
|
+
name: 'registerDelegate',
|
|
20
|
+
stateMutability: 'payable',
|
|
21
|
+
inputs: [
|
|
22
|
+
{ name: 'delegate', type: 'address' },
|
|
23
|
+
{ name: 'payee', type: 'address' },
|
|
24
|
+
],
|
|
25
|
+
outputs: [],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'function',
|
|
29
|
+
name: 'registerDelegateViaSignature',
|
|
30
|
+
stateMutability: 'payable',
|
|
31
|
+
inputs: [
|
|
32
|
+
{ name: 'owner', type: 'address' },
|
|
33
|
+
{ name: 'delegate', type: 'address' },
|
|
34
|
+
{ name: 'deadline', type: 'uint256' },
|
|
35
|
+
{ name: 'signature', type: 'bytes' },
|
|
36
|
+
],
|
|
37
|
+
outputs: [],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'function',
|
|
41
|
+
name: 'revokeDelegate',
|
|
42
|
+
stateMutability: 'nonpayable',
|
|
43
|
+
inputs: [{ name: 'delegate', type: 'address' }],
|
|
44
|
+
outputs: [],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'function',
|
|
48
|
+
name: 'delegationStatus',
|
|
49
|
+
stateMutability: 'view',
|
|
50
|
+
inputs: [
|
|
51
|
+
{ name: 'owner', type: 'address' },
|
|
52
|
+
{ name: 'delegate', type: 'address' },
|
|
53
|
+
],
|
|
54
|
+
outputs: [
|
|
55
|
+
{ name: 'allowed', type: 'bool' },
|
|
56
|
+
{ name: 'withdrawn', type: 'bool' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
// `view`, not `pure`: the contract and the chain come from `address(this)` and
|
|
61
|
+
// `block.chainid` rather than from arguments, which is what stops a caller choosing them.
|
|
62
|
+
type: 'function',
|
|
63
|
+
name: 'delegationMessage',
|
|
64
|
+
stateMutability: 'view',
|
|
65
|
+
inputs: [
|
|
66
|
+
{ name: 'delegate', type: 'address' },
|
|
67
|
+
{ name: 'deadline', type: 'uint256' },
|
|
68
|
+
],
|
|
69
|
+
outputs: [{ name: '', type: 'string' }],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'function',
|
|
73
|
+
name: 'delegationDigest',
|
|
74
|
+
stateMutability: 'view',
|
|
75
|
+
inputs: [
|
|
76
|
+
{ name: 'delegate', type: 'address' },
|
|
77
|
+
{ name: 'deadline', type: 'uint256' },
|
|
78
|
+
],
|
|
79
|
+
outputs: [{ name: '', type: 'bytes32' }],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'event',
|
|
83
|
+
name: 'DelegationChanged',
|
|
84
|
+
anonymous: false,
|
|
85
|
+
inputs: [
|
|
86
|
+
{ name: 'owner', type: 'address', indexed: true },
|
|
87
|
+
{ name: 'delegate', type: 'address', indexed: true },
|
|
88
|
+
{ name: 'allowed', type: 'bool', indexed: false },
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'error',
|
|
93
|
+
name: 'NotDelegate',
|
|
94
|
+
inputs: [
|
|
95
|
+
{ name: 'owner', type: 'address' },
|
|
96
|
+
{ name: 'sender', type: 'address' },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'error',
|
|
101
|
+
name: 'DelegationWithdrawn',
|
|
102
|
+
inputs: [
|
|
103
|
+
{ name: 'owner', type: 'address' },
|
|
104
|
+
{ name: 'delegate', type: 'address' },
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'error',
|
|
109
|
+
name: 'InvalidSignature',
|
|
110
|
+
inputs: [],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'error',
|
|
114
|
+
name: 'InvalidDelegate',
|
|
115
|
+
inputs: [],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: 'error',
|
|
119
|
+
name: 'SignatureExpired',
|
|
120
|
+
inputs: [{ name: 'deadline', type: 'uint256' }],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'error',
|
|
124
|
+
name: 'MalformedSignature',
|
|
125
|
+
inputs: [],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: 'error',
|
|
129
|
+
name: 'UnrecoverableSignature',
|
|
130
|
+
inputs: [],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: 'error',
|
|
134
|
+
name: 'TransferFailed',
|
|
135
|
+
inputs: [{ name: 'payee', type: 'address' }],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'error',
|
|
139
|
+
name: 'ValueWithNoPayee',
|
|
140
|
+
inputs: [{ name: 'amount', type: 'uint256' }],
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One feature with three faces, shipped together on purpose.
|
|
3
|
+
*
|
|
4
|
+
* - the Solidity, in `contracts/`, consumed through node_modules and compiled INTO each adopter;
|
|
5
|
+
* - the TypeScript builder below, which produces the exact bytes that Solidity verifies;
|
|
6
|
+
* - the ABI, for a client calling a contract it does not compile against.
|
|
7
|
+
*
|
|
8
|
+
* They are together because the thing that breaks is agreement between them, and it breaks
|
|
9
|
+
* silently: a signature over a message that differs by one byte does not fail loudly, it simply
|
|
10
|
+
* recovers a different address. Co-located, the test that pins them runs on every change to either.
|
|
11
|
+
*/
|
|
12
|
+
export { delegationMessage, delegationDigest, type DelegationTerms } from './message.js';
|
|
13
|
+
export { DELEGATION_ABI } from './abi.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAC,MAAM,cAAc,CAAC;AACvF,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One feature with three faces, shipped together on purpose.
|
|
3
|
+
*
|
|
4
|
+
* - the Solidity, in `contracts/`, consumed through node_modules and compiled INTO each adopter;
|
|
5
|
+
* - the TypeScript builder below, which produces the exact bytes that Solidity verifies;
|
|
6
|
+
* - the ABI, for a client calling a contract it does not compile against.
|
|
7
|
+
*
|
|
8
|
+
* They are together because the thing that breaks is agreement between them, and it breaks
|
|
9
|
+
* silently: a signature over a message that differs by one byte does not fail loudly, it simply
|
|
10
|
+
* recovers a different address. Co-located, the test that pins them runs on every change to either.
|
|
11
|
+
*/
|
|
12
|
+
export { delegationMessage, delegationDigest } from './message.js';
|
|
13
|
+
export { DELEGATION_ABI } from './abi.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAuB,MAAM,cAAc,CAAC;AACvF,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one delegation authorises, and the whole of it.
|
|
3
|
+
*
|
|
4
|
+
* Every field is inside the signed bytes. Anything stored beside a signature is a CACHE of what is
|
|
5
|
+
* in it, never metadata about it: if a stored copy disagrees with the signed copy there is no way
|
|
6
|
+
* to notice locally, the signature simply fails to recover, so the remedy for a signature failure
|
|
7
|
+
* is to throw the record away and ask for a fresh one rather than to report a contract error.
|
|
8
|
+
*/
|
|
9
|
+
export type DelegationTerms = {
|
|
10
|
+
/** the address being authorised to act for the owner */
|
|
11
|
+
delegate: `0x${string}`;
|
|
12
|
+
/** the contract the authorisation is good at, and nowhere else */
|
|
13
|
+
contract: `0x${string}`;
|
|
14
|
+
/** the chain that contract is on */
|
|
15
|
+
chainId: number | bigint;
|
|
16
|
+
/** unix seconds after which the signature stops being registrable; 0 means no expiry */
|
|
17
|
+
deadline: number | bigint;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The exact text an owner signs to authorise a delegate at one contract on one chain.
|
|
21
|
+
*
|
|
22
|
+
* Addresses are lowercased HERE rather than at the call site, so no caller can hand us an EIP-55
|
|
23
|
+
* checksummed spelling that then fails to verify onchain. The deadline is decimal unix seconds, or
|
|
24
|
+
* the word `never` for 0; `Expires` stays a line either way, since an absent line is easy for a
|
|
25
|
+
* human to miss and easy for a parser to treat as an unset default.
|
|
26
|
+
*/
|
|
27
|
+
export declare function delegationMessage(terms: DelegationTerms): string;
|
|
28
|
+
/**
|
|
29
|
+
* The EIP-191 `personal_sign` digest of {@link delegationMessage}.
|
|
30
|
+
*
|
|
31
|
+
* The same bytes `SignatureUtils.textDigest` builds onchain: the text with the fixed prefix and its
|
|
32
|
+
* own byte LENGTH in front. Exported so a wallet can check a signature it is about to store, and so
|
|
33
|
+
* the vectors pin the digest rather than only the string - a length prefix computed in characters
|
|
34
|
+
* instead of bytes produces an identical-looking message and a different digest.
|
|
35
|
+
*/
|
|
36
|
+
export declare function delegationDigest(terms: DelegationTerms): `0x${string}`;
|
|
37
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,wDAAwD;IACxD,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,kEAAkE;IAClE,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,oCAAoC;IACpC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B,CAAC;AAkBF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAYhE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,MAAM,EAAE,CAOtE"}
|
package/dist/message.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { keccak_256 } from '@noble/hashes/sha3';
|
|
2
|
+
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
|
3
|
+
// The verifying contract reproduces this wording literally, character for character, and renders
|
|
4
|
+
// both addresses lowercase. The wording, the field order and the casing are consensus, not style:
|
|
5
|
+
// change any of it and every signature ever generated silently stops verifying, with no error that
|
|
6
|
+
// points at the cause.
|
|
7
|
+
//
|
|
8
|
+
// The three implementations are this file, `contracts/Delegation.sol`, and whatever a third-party
|
|
9
|
+
// wallet writes. They are pinned against `vectors.json` at the root of this package, from both
|
|
10
|
+
// languages. NEVER change one side without the others and the vectors, in the same commit.
|
|
11
|
+
const HEAD = 'IMPORTANT: Only sign this on a site you trust.\n' +
|
|
12
|
+
'\n' +
|
|
13
|
+
'This authorizes another address to act in your name onchain, at one contract.\n' +
|
|
14
|
+
'You can withdraw it at any time by revoking it there.\n' +
|
|
15
|
+
'\n' +
|
|
16
|
+
'Delegate: ';
|
|
17
|
+
/**
|
|
18
|
+
* The exact text an owner signs to authorise a delegate at one contract on one chain.
|
|
19
|
+
*
|
|
20
|
+
* Addresses are lowercased HERE rather than at the call site, so no caller can hand us an EIP-55
|
|
21
|
+
* checksummed spelling that then fails to verify onchain. The deadline is decimal unix seconds, or
|
|
22
|
+
* the word `never` for 0; `Expires` stays a line either way, since an absent line is easy for a
|
|
23
|
+
* human to miss and easy for a parser to treat as an unset default.
|
|
24
|
+
*/
|
|
25
|
+
export function delegationMessage(terms) {
|
|
26
|
+
const expires = BigInt(terms.deadline) === 0n ? 'never' : BigInt(terms.deadline).toString(10);
|
|
27
|
+
return (HEAD +
|
|
28
|
+
terms.delegate.toLowerCase() +
|
|
29
|
+
'\nContract: ' +
|
|
30
|
+
terms.contract.toLowerCase() +
|
|
31
|
+
'\nChain ID: ' +
|
|
32
|
+
BigInt(terms.chainId).toString(10) +
|
|
33
|
+
'\nExpires: ' +
|
|
34
|
+
expires);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The EIP-191 `personal_sign` digest of {@link delegationMessage}.
|
|
38
|
+
*
|
|
39
|
+
* The same bytes `SignatureUtils.textDigest` builds onchain: the text with the fixed prefix and its
|
|
40
|
+
* own byte LENGTH in front. Exported so a wallet can check a signature it is about to store, and so
|
|
41
|
+
* the vectors pin the digest rather than only the string - a length prefix computed in characters
|
|
42
|
+
* instead of bytes produces an identical-looking message and a different digest.
|
|
43
|
+
*/
|
|
44
|
+
export function delegationDigest(terms) {
|
|
45
|
+
const message = utf8ToBytes(delegationMessage(terms));
|
|
46
|
+
const prefix = utf8ToBytes(`\x19Ethereum Signed Message:\n${message.length}`);
|
|
47
|
+
const full = new Uint8Array(prefix.length + message.length);
|
|
48
|
+
full.set(prefix, 0);
|
|
49
|
+
full.set(message, prefix.length);
|
|
50
|
+
return `0x${bytesToHex(keccak_256(full))}`;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAqB5D,iGAAiG;AACjG,kGAAkG;AAClG,mGAAmG;AACnG,uBAAuB;AACvB,EAAE;AACF,kGAAkG;AAClG,+FAA+F;AAC/F,2FAA2F;AAC3F,MAAM,IAAI,GACT,kDAAkD;IAClD,IAAI;IACJ,iFAAiF;IACjF,yDAAyD;IACzD,IAAI;IACJ,YAAY,CAAC;AAEd;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAsB;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC9F,OAAO,CACN,IAAI;QACJ,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE;QAC5B,cAAc;QACd,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE;QAC5B,cAAc;QACd,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,aAAa;QACb,OAAO,CACP,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACtD,MAAM,OAAO,GAAG,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,WAAW,CAAC,iCAAiC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,KAAK,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etherplay/delegation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Onchain delegation for Etherplay Accounts - Solidity library, the TypeScript builder for the message it verifies, and the ABI, kept in agreement by a shared vectors file",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ethereum",
|
|
7
|
+
"solidity",
|
|
8
|
+
"delegation",
|
|
9
|
+
"session-key",
|
|
10
|
+
"erc-7201",
|
|
11
|
+
"eip-191",
|
|
12
|
+
"signature",
|
|
13
|
+
"web3",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/wighawag/etherplay-connect#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/wighawag/etherplay-connect.git",
|
|
20
|
+
"directory": "packages/etherplay-delegation"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/wighawag/etherplay-connect/issues"
|
|
24
|
+
},
|
|
25
|
+
"author": "Ronan Sandford",
|
|
26
|
+
"license": "MIT",
|
|
4
27
|
"publishConfig": {
|
|
5
28
|
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./contracts/*": "./contracts/*",
|
|
37
|
+
"./vectors.json": "./vectors.json",
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"contracts",
|
|
42
|
+
"dist",
|
|
43
|
+
"src",
|
|
44
|
+
"vectors.json"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@noble/hashes": "^1.7.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@nomicfoundation/hardhat-node-test-runner": "^3.1.0",
|
|
51
|
+
"@nomicfoundation/hardhat-viem": "^3.0.6",
|
|
52
|
+
"@types/node": "^24.0.0",
|
|
53
|
+
"as-soon": "^0.0.11",
|
|
54
|
+
"earl": "^2.0.0",
|
|
55
|
+
"forge-std": "github:foundry-rs/forge-std#v1.9.4",
|
|
56
|
+
"hardhat": "^3.12.0",
|
|
57
|
+
"prettier": "^3.5.3",
|
|
58
|
+
"prettier-plugin-solidity": "^2.4.0",
|
|
59
|
+
"typescript": "^5.8.3",
|
|
60
|
+
"viem": "^2.55.11"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc --project tsconfig.json",
|
|
64
|
+
"dev": "as-soon -w src pnpm build",
|
|
65
|
+
"compile": "hardhat compile",
|
|
66
|
+
"format:check": "prettier --check .",
|
|
67
|
+
"format": "prettier --write .",
|
|
68
|
+
"test": "hardhat test"
|
|
6
69
|
}
|
|
7
|
-
}
|
|
70
|
+
}
|
package/src/abi.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The delegation surface as an ABI, for a client that calls a contract it does not compile against.
|
|
3
|
+
*
|
|
4
|
+
* The same six functions {@link file://../contracts/IDelegation.sol} declares, plus the event and
|
|
5
|
+
* the errors an adopter of `UsingDelegation` actually exposes - the event because it IS the
|
|
6
|
+
* enumeration API (there is no onchain list of an account's delegates, so the set is reconstructed
|
|
7
|
+
* by replaying these logs), and the errors so a revert decodes into something an app can act on
|
|
8
|
+
* rather than a hex blob.
|
|
9
|
+
*
|
|
10
|
+
* Hand-written rather than generated, so it reads as the contract's surface and ships without a
|
|
11
|
+
* build artifact. Drift is caught instead of prevented: a test compiles the Solidity and asserts
|
|
12
|
+
* this is exactly its ABI, so adding a parameter on one side and not the other fails in CI.
|
|
13
|
+
*
|
|
14
|
+
* `as const`, so viem infers argument and return types from it.
|
|
15
|
+
*/
|
|
16
|
+
export const DELEGATION_ABI = [
|
|
17
|
+
{
|
|
18
|
+
type: 'function',
|
|
19
|
+
name: 'registerDelegate',
|
|
20
|
+
stateMutability: 'payable',
|
|
21
|
+
inputs: [
|
|
22
|
+
{name: 'delegate', type: 'address'},
|
|
23
|
+
{name: 'payee', type: 'address'},
|
|
24
|
+
],
|
|
25
|
+
outputs: [],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'function',
|
|
29
|
+
name: 'registerDelegateViaSignature',
|
|
30
|
+
stateMutability: 'payable',
|
|
31
|
+
inputs: [
|
|
32
|
+
{name: 'owner', type: 'address'},
|
|
33
|
+
{name: 'delegate', type: 'address'},
|
|
34
|
+
{name: 'deadline', type: 'uint256'},
|
|
35
|
+
{name: 'signature', type: 'bytes'},
|
|
36
|
+
],
|
|
37
|
+
outputs: [],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'function',
|
|
41
|
+
name: 'revokeDelegate',
|
|
42
|
+
stateMutability: 'nonpayable',
|
|
43
|
+
inputs: [{name: 'delegate', type: 'address'}],
|
|
44
|
+
outputs: [],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'function',
|
|
48
|
+
name: 'delegationStatus',
|
|
49
|
+
stateMutability: 'view',
|
|
50
|
+
inputs: [
|
|
51
|
+
{name: 'owner', type: 'address'},
|
|
52
|
+
{name: 'delegate', type: 'address'},
|
|
53
|
+
],
|
|
54
|
+
outputs: [
|
|
55
|
+
{name: 'allowed', type: 'bool'},
|
|
56
|
+
{name: 'withdrawn', type: 'bool'},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
// `view`, not `pure`: the contract and the chain come from `address(this)` and
|
|
61
|
+
// `block.chainid` rather than from arguments, which is what stops a caller choosing them.
|
|
62
|
+
type: 'function',
|
|
63
|
+
name: 'delegationMessage',
|
|
64
|
+
stateMutability: 'view',
|
|
65
|
+
inputs: [
|
|
66
|
+
{name: 'delegate', type: 'address'},
|
|
67
|
+
{name: 'deadline', type: 'uint256'},
|
|
68
|
+
],
|
|
69
|
+
outputs: [{name: '', type: 'string'}],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'function',
|
|
73
|
+
name: 'delegationDigest',
|
|
74
|
+
stateMutability: 'view',
|
|
75
|
+
inputs: [
|
|
76
|
+
{name: 'delegate', type: 'address'},
|
|
77
|
+
{name: 'deadline', type: 'uint256'},
|
|
78
|
+
],
|
|
79
|
+
outputs: [{name: '', type: 'bytes32'}],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'event',
|
|
83
|
+
name: 'DelegationChanged',
|
|
84
|
+
anonymous: false,
|
|
85
|
+
inputs: [
|
|
86
|
+
{name: 'owner', type: 'address', indexed: true},
|
|
87
|
+
{name: 'delegate', type: 'address', indexed: true},
|
|
88
|
+
{name: 'allowed', type: 'bool', indexed: false},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'error',
|
|
93
|
+
name: 'NotDelegate',
|
|
94
|
+
inputs: [
|
|
95
|
+
{name: 'owner', type: 'address'},
|
|
96
|
+
{name: 'sender', type: 'address'},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'error',
|
|
101
|
+
name: 'DelegationWithdrawn',
|
|
102
|
+
inputs: [
|
|
103
|
+
{name: 'owner', type: 'address'},
|
|
104
|
+
{name: 'delegate', type: 'address'},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'error',
|
|
109
|
+
name: 'InvalidSignature',
|
|
110
|
+
inputs: [],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'error',
|
|
114
|
+
name: 'InvalidDelegate',
|
|
115
|
+
inputs: [],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: 'error',
|
|
119
|
+
name: 'SignatureExpired',
|
|
120
|
+
inputs: [{name: 'deadline', type: 'uint256'}],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'error',
|
|
124
|
+
name: 'MalformedSignature',
|
|
125
|
+
inputs: [],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: 'error',
|
|
129
|
+
name: 'UnrecoverableSignature',
|
|
130
|
+
inputs: [],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: 'error',
|
|
134
|
+
name: 'TransferFailed',
|
|
135
|
+
inputs: [{name: 'payee', type: 'address'}],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'error',
|
|
139
|
+
name: 'ValueWithNoPayee',
|
|
140
|
+
inputs: [{name: 'amount', type: 'uint256'}],
|
|
141
|
+
},
|
|
142
|
+
] as const;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One feature with three faces, shipped together on purpose.
|
|
3
|
+
*
|
|
4
|
+
* - the Solidity, in `contracts/`, consumed through node_modules and compiled INTO each adopter;
|
|
5
|
+
* - the TypeScript builder below, which produces the exact bytes that Solidity verifies;
|
|
6
|
+
* - the ABI, for a client calling a contract it does not compile against.
|
|
7
|
+
*
|
|
8
|
+
* They are together because the thing that breaks is agreement between them, and it breaks
|
|
9
|
+
* silently: a signature over a message that differs by one byte does not fail loudly, it simply
|
|
10
|
+
* recovers a different address. Co-located, the test that pins them runs on every change to either.
|
|
11
|
+
*/
|
|
12
|
+
export {delegationMessage, delegationDigest, type DelegationTerms} from './message.js';
|
|
13
|
+
export {DELEGATION_ABI} from './abi.js';
|
package/src/message.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {keccak_256} from '@noble/hashes/sha3';
|
|
2
|
+
import {bytesToHex, utf8ToBytes} from '@noble/hashes/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What one delegation authorises, and the whole of it.
|
|
6
|
+
*
|
|
7
|
+
* Every field is inside the signed bytes. Anything stored beside a signature is a CACHE of what is
|
|
8
|
+
* in it, never metadata about it: if a stored copy disagrees with the signed copy there is no way
|
|
9
|
+
* to notice locally, the signature simply fails to recover, so the remedy for a signature failure
|
|
10
|
+
* is to throw the record away and ask for a fresh one rather than to report a contract error.
|
|
11
|
+
*/
|
|
12
|
+
export type DelegationTerms = {
|
|
13
|
+
/** the address being authorised to act for the owner */
|
|
14
|
+
delegate: `0x${string}`;
|
|
15
|
+
/** the contract the authorisation is good at, and nowhere else */
|
|
16
|
+
contract: `0x${string}`;
|
|
17
|
+
/** the chain that contract is on */
|
|
18
|
+
chainId: number | bigint;
|
|
19
|
+
/** unix seconds after which the signature stops being registrable; 0 means no expiry */
|
|
20
|
+
deadline: number | bigint;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// The verifying contract reproduces this wording literally, character for character, and renders
|
|
24
|
+
// both addresses lowercase. The wording, the field order and the casing are consensus, not style:
|
|
25
|
+
// change any of it and every signature ever generated silently stops verifying, with no error that
|
|
26
|
+
// points at the cause.
|
|
27
|
+
//
|
|
28
|
+
// The three implementations are this file, `contracts/Delegation.sol`, and whatever a third-party
|
|
29
|
+
// wallet writes. They are pinned against `vectors.json` at the root of this package, from both
|
|
30
|
+
// languages. NEVER change one side without the others and the vectors, in the same commit.
|
|
31
|
+
const HEAD =
|
|
32
|
+
'IMPORTANT: Only sign this on a site you trust.\n' +
|
|
33
|
+
'\n' +
|
|
34
|
+
'This authorizes another address to act in your name onchain, at one contract.\n' +
|
|
35
|
+
'You can withdraw it at any time by revoking it there.\n' +
|
|
36
|
+
'\n' +
|
|
37
|
+
'Delegate: ';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The exact text an owner signs to authorise a delegate at one contract on one chain.
|
|
41
|
+
*
|
|
42
|
+
* Addresses are lowercased HERE rather than at the call site, so no caller can hand us an EIP-55
|
|
43
|
+
* checksummed spelling that then fails to verify onchain. The deadline is decimal unix seconds, or
|
|
44
|
+
* the word `never` for 0; `Expires` stays a line either way, since an absent line is easy for a
|
|
45
|
+
* human to miss and easy for a parser to treat as an unset default.
|
|
46
|
+
*/
|
|
47
|
+
export function delegationMessage(terms: DelegationTerms): string {
|
|
48
|
+
const expires = BigInt(terms.deadline) === 0n ? 'never' : BigInt(terms.deadline).toString(10);
|
|
49
|
+
return (
|
|
50
|
+
HEAD +
|
|
51
|
+
terms.delegate.toLowerCase() +
|
|
52
|
+
'\nContract: ' +
|
|
53
|
+
terms.contract.toLowerCase() +
|
|
54
|
+
'\nChain ID: ' +
|
|
55
|
+
BigInt(terms.chainId).toString(10) +
|
|
56
|
+
'\nExpires: ' +
|
|
57
|
+
expires
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The EIP-191 `personal_sign` digest of {@link delegationMessage}.
|
|
63
|
+
*
|
|
64
|
+
* The same bytes `SignatureUtils.textDigest` builds onchain: the text with the fixed prefix and its
|
|
65
|
+
* own byte LENGTH in front. Exported so a wallet can check a signature it is about to store, and so
|
|
66
|
+
* the vectors pin the digest rather than only the string - a length prefix computed in characters
|
|
67
|
+
* instead of bytes produces an identical-looking message and a different digest.
|
|
68
|
+
*/
|
|
69
|
+
export function delegationDigest(terms: DelegationTerms): `0x${string}` {
|
|
70
|
+
const message = utf8ToBytes(delegationMessage(terms));
|
|
71
|
+
const prefix = utf8ToBytes(`\x19Ethereum Signed Message:\n${message.length}`);
|
|
72
|
+
const full = new Uint8Array(prefix.length + message.length);
|
|
73
|
+
full.set(prefix, 0);
|
|
74
|
+
full.set(message, prefix.length);
|
|
75
|
+
return `0x${bytesToHex(keccak_256(full))}`;
|
|
76
|
+
}
|
package/vectors.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Consensus test vectors for the delegation message. Three implementations must agree on these bytes: contracts/Delegation.sol, src/message.ts, and any third-party wallet that signs one. Each case gives the terms, the exact message string and its EIP-191 digest. Both languages are tested against this file (test/solidity/Vectors.t.sol and test/js/vectors.test.ts). CHANGING A LINE HERE INVALIDATES EVERY SIGNATURE EVER GENERATED: it is not a test fixture, it is the specification.",
|
|
3
|
+
"cases": [
|
|
4
|
+
{
|
|
5
|
+
"name": "no expiry, mainnet",
|
|
6
|
+
"why": "The ordinary prompted credential: a deadline of zero renders as the word never, and stays a line.",
|
|
7
|
+
"delegate": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
|
|
8
|
+
"contract": "0x5fbdb2315678afecb367f032d93f642f64180aa3",
|
|
9
|
+
"chainId": 1,
|
|
10
|
+
"deadline": 0,
|
|
11
|
+
"message": "IMPORTANT: Only sign this on a site you trust.\n\nThis authorizes another address to act in your name onchain, at one contract.\nYou can withdraw it at any time by revoking it there.\n\nDelegate: 0xd8da6bf26964af9d7eed9e03e53415d37aa96045\nContract: 0x5fbdb2315678afecb367f032d93f642f64180aa3\nChain ID: 1\nExpires: never",
|
|
12
|
+
"digest": "0x6c61d40540268a66427acd15b66522b3536a9ccfc42a0b4b4f55ada4003a5aa3"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "a real deadline, dev chain",
|
|
16
|
+
"why": "The auto-signed, allowlisted credential: a unix timestamp in decimal, on the chain id a local node uses.",
|
|
17
|
+
"delegate": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
|
|
18
|
+
"contract": "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512",
|
|
19
|
+
"chainId": 31337,
|
|
20
|
+
"deadline": 1767225600,
|
|
21
|
+
"message": "IMPORTANT: Only sign this on a site you trust.\n\nThis authorizes another address to act in your name onchain, at one contract.\nYou can withdraw it at any time by revoking it there.\n\nDelegate: 0x70997970c51812dc3a010c7d01b50e0d17dc79c8\nContract: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512\nChain ID: 31337\nExpires: 1767225600",
|
|
22
|
+
"digest": "0x3edf0fd7ae5d80a942a8a0209a2660c225c38a1a1a5c3ac107f418bab0897477"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "checksummed input, lowercase output",
|
|
26
|
+
"why": "Same terms as the first case, spelled EIP-55. Both sides must lowercase, so this must produce byte-identical output to it; a checksumming implementation produces a different message and every signature it makes is rejected onchain.",
|
|
27
|
+
"delegate": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
|
|
28
|
+
"contract": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
|
29
|
+
"chainId": 1,
|
|
30
|
+
"deadline": 0,
|
|
31
|
+
"message": "IMPORTANT: Only sign this on a site you trust.\n\nThis authorizes another address to act in your name onchain, at one contract.\nYou can withdraw it at any time by revoking it there.\n\nDelegate: 0xd8da6bf26964af9d7eed9e03e53415d37aa96045\nContract: 0x5fbdb2315678afecb367f032d93f642f64180aa3\nChain ID: 1\nExpires: never",
|
|
32
|
+
"digest": "0x6c61d40540268a66427acd15b66522b3536a9ccfc42a0b4b4f55ada4003a5aa3"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "the smallest non-zero deadline",
|
|
36
|
+
"why": "One second past the epoch: long expired, and NOT the same as no expiry. The boundary an implementation crosses if it treats a falsy deadline as absent.",
|
|
37
|
+
"delegate": "0x0000000000000000000000000000000000000001",
|
|
38
|
+
"contract": "0xffffffffffffffffffffffffffffffffffffffff",
|
|
39
|
+
"chainId": 1,
|
|
40
|
+
"deadline": 1,
|
|
41
|
+
"message": "IMPORTANT: Only sign this on a site you trust.\n\nThis authorizes another address to act in your name onchain, at one contract.\nYou can withdraw it at any time by revoking it there.\n\nDelegate: 0x0000000000000000000000000000000000000001\nContract: 0xffffffffffffffffffffffffffffffffffffffff\nChain ID: 1\nExpires: 1",
|
|
42
|
+
"digest": "0xe570707d7c125d5132977c7e01b3cd86652467e99408667e63caeb70dd22832b"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "a far deadline, dev chain",
|
|
46
|
+
"why": "A ten-digit timestamp against a five-digit chain id, so a decimal renderer that pads, truncates or thousands-separates either one is caught.",
|
|
47
|
+
"delegate": "0xffffffffffffffffffffffffffffffffffffffff",
|
|
48
|
+
"contract": "0x000000000000000000000000000000000000dead",
|
|
49
|
+
"chainId": 31337,
|
|
50
|
+
"deadline": 4102444800,
|
|
51
|
+
"message": "IMPORTANT: Only sign this on a site you trust.\n\nThis authorizes another address to act in your name onchain, at one contract.\nYou can withdraw it at any time by revoking it there.\n\nDelegate: 0xffffffffffffffffffffffffffffffffffffffff\nContract: 0x000000000000000000000000000000000000dead\nChain ID: 31337\nExpires: 4102444800",
|
|
52
|
+
"digest": "0x988c49a719033f8a79ea4724cac29d557a6f84b02b2a8e77a5ac7ac5b246b3d2"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|