@meantjs/profile 0.2.0 → 0.3.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/CHANGELOG.md +15 -0
- package/README.md +12 -4
- package/data/packs/dai-permit.profile.json +113 -0
- package/data/packs/erc2612.profile.json +196 -0
- package/data/packs/permit2.profile.json +436 -0
- package/data/profile-v0.schema.json +151 -9
- package/data/profile-v0.validate.mjs +11 -2
- package/package.json +1 -1
- package/src/abi-iface.mjs +49 -7
- package/src/abi-pack.mjs +5 -2
- package/src/abi.mjs +111 -4
- package/src/analyze.mjs +13 -3
- package/src/browser.mjs +6 -1
- package/src/checks.mjs +21 -1
- package/src/evm.d.mts +18 -3
- package/src/evm.mjs +5 -1
- package/src/resolve.mjs +45 -7
- package/src/resolved.mjs +14 -2
- package/src/validate.mjs +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
The five Candid Profile library packages (`@meantjs/profile`, `/format`, `/consent`, `/tools`, `/reconcile`) release together under one version and pin each other exactly; a version appears here even when this package did not change. Release steps: `docs/releasing.md` in the repository.
|
|
4
4
|
|
|
5
|
+
## 0.3.0 — 2026-10-29
|
|
6
|
+
|
|
7
|
+
- EIP-712 typed messages, experimental (spec §15.9, D-055). A contract profile or EVM pack may carry
|
|
8
|
+
`binds.eip712: { domain?, types }`, and a contract profile may have it instead of `binds.abi`. A message is a type
|
|
9
|
+
the same document tags with `intent`, addressed like a function (`PermitSingle(0).details.amount`); the resolved form
|
|
10
|
+
lists messages under a new `messages` map (`encode_type`, `type_hash`, `tags`, `args`) and the bound domain as
|
|
11
|
+
`profiles[].eip712_domain`. Without types, the resolved form and the interface id are unchanged.
|
|
12
|
+
- `amount` takes `token`, a relative path to the `address` field that names its token (EVM only); `timestamp` takes
|
|
13
|
+
`threshold` with `message`, and `labels` (display only). New errors `E_EIP712` and `E_TOKEN_PATH`.
|
|
14
|
+
- `@meantjs/profile/evm` exports `encodeType`, `eip712TypeHash` and `parseEip712Types`; `abiInterfaceId` takes the
|
|
15
|
+
struct types as a second argument.
|
|
16
|
+
- New standard files: the `erc2612` pack (in `STANDARD_PACKS` and `loadPacks()`), and the `permit2` and `dai-permit`
|
|
17
|
+
contract profiles, shipped beside the packs (`@meantjs/profile/packs/permit2.profile.json`); `loadPacks()` returns
|
|
18
|
+
packs only, as before.
|
|
19
|
+
|
|
5
20
|
## 0.2.0 — 2026-10-28
|
|
6
21
|
|
|
7
22
|
- `intent` and `effect` may sit on a case of a variant in a method's arguments, such as `propose(0).Transfer`
|
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ const r = await resolveService({ did: serviceText, profiles: served.ok ? [{ doc:
|
|
|
164
164
|
serves, so a profile for another interface is `rebound` or `stale` as any other.
|
|
165
165
|
- Tests: `test/served.test.mjs`; end to end on PocketIC in `packages/kit/pocketic/`.
|
|
166
166
|
|
|
167
|
-
## EVM contracts (experimental, spec section 15, D-054)
|
|
167
|
+
## EVM contracts (experimental, spec section 15, D-054 and D-055)
|
|
168
168
|
|
|
169
169
|
A third input, `abi`: an EVM contract's ABI as human-readable fragments or JSON ABI entries. The resolver reads it as
|
|
170
170
|
the graph a `.did` compiles to (a function is a method, its parameters one record at argument 0, a tuple a record in
|
|
@@ -181,15 +181,23 @@ r.resolved.methods.transfer.tags.intent.args.template; // "Send {wad} to {dst}":
|
|
|
181
181
|
that has every one of their functions, by selector, output types and kind of call (no subtyping); their addresses
|
|
182
182
|
and placeholders are rewritten to the contract's parameter names by position. A pack or profile for the other kind
|
|
183
183
|
of interface is `E_CHAIN` when given, and skipped in a pack search, so `loadPacks()` serves both kinds.
|
|
184
|
+
- **EIP-712 messages** (spec §15.9, D-055): `binds.eip712: { domain?, types }` in a contract profile (with or without
|
|
185
|
+
`binds.abi`) or an EVM pack. A type the same document tags with `intent` is a message, addressed like a function
|
|
186
|
+
(`PermitSingle(0).details.amount`) and listed under the resolved form's `messages` with its `encode_type` and
|
|
187
|
+
`type_hash`. `amount.token` names an amount's token by an `address` field (`E_TOKEN_PATH` otherwise). Bad types, a
|
|
188
|
+
message named like a function and two meanings for one type name are `E_EIP712`. Standard files: the `erc2612`
|
|
189
|
+
pack, and the `permit2` and `dai-permit` contract profiles shipped beside the packs
|
|
190
|
+
(`@meantjs/profile/packs/permit2.profile.json`); `loadPacks()` returns the packs only.
|
|
184
191
|
- **Refused for now:** overloaded function names and unreadable fragments (`E_ABI`); `idempotency`, `outcome`, `list`,
|
|
185
192
|
`names` and `named` on a contract (`E_TAG_TARGET`); `account` and `subaccount` (`E_TAG_NOT_APPLICABLE`); `[ ]`
|
|
186
193
|
template segments (`E_TEMPLATE`).
|
|
187
194
|
- **`@meantjs/profile/evm`** is the toolkit underneath, browser-safe and without dependencies: `keccak256`, `parseAbi`,
|
|
188
195
|
`parseSignature`, `canonicalFragment`, `selectorOf`, `abiInterfaceId`, a strict codec (`encodeParams`, `encodeCall`,
|
|
189
196
|
`decodeParams`: a value read from anything but its canonical encoding is refused), `toChecksumAddress`,
|
|
190
|
-
`readAddress
|
|
191
|
-
implementation (and the block boundary), the ERC-20
|
|
192
|
-
EIP-712's Mail example.
|
|
197
|
+
`readAddress`, `typedDataDigest` (EIP-712), `encodeType`, `eip712TypeHash` and `parseEip712Types`.
|
|
198
|
+
`test/evm.test.mjs` checks Keccak against an independent implementation (and the block boundary), the ERC-20
|
|
199
|
+
selectors, the ERC-8176 schema UID, EIP-55's examples and EIP-712's Mail example; `test/eip712.test.mjs` the type
|
|
200
|
+
hashes of the standard messages (DAI's equals `dai.sol`'s constant).
|
|
193
201
|
|
|
194
202
|
## CLI
|
|
195
203
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "candid-profile",
|
|
3
|
+
"format_version": 0,
|
|
4
|
+
"kind": "contract",
|
|
5
|
+
"name": "dai-permit",
|
|
6
|
+
"origin": "third_party",
|
|
7
|
+
"language": "en",
|
|
8
|
+
"description": "DAI's permit on Ethereum mainnet (spec section 15.9, experimental), older than EIP-2612 and different from it: `allowed` sets the allowance to all of the holder's DAI (true, uint256 max) or to none (false), and `expiry` 0 means the signature never expires (MakerDAO dss, src/dai.sol). Only the message is described; DAI's functions are ERC-20's and the erc20 pack covers them.",
|
|
9
|
+
"binds": {
|
|
10
|
+
"eip712": {
|
|
11
|
+
"domain": {
|
|
12
|
+
"name": "Dai Stablecoin",
|
|
13
|
+
"version": "1"
|
|
14
|
+
},
|
|
15
|
+
"types": {
|
|
16
|
+
"Permit": [
|
|
17
|
+
{
|
|
18
|
+
"name": "holder",
|
|
19
|
+
"type": "address"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "spender",
|
|
23
|
+
"type": "address"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "nonce",
|
|
27
|
+
"type": "uint256"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "expiry",
|
|
31
|
+
"type": "uint256"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "allowed",
|
|
35
|
+
"type": "bool"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"deployments": [
|
|
41
|
+
{
|
|
42
|
+
"chain_id": 1,
|
|
43
|
+
"address": "0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"annotations": [
|
|
48
|
+
{
|
|
49
|
+
"at": "Permit",
|
|
50
|
+
"tag": "intent",
|
|
51
|
+
"args": {
|
|
52
|
+
"title": "Permit DAI spending",
|
|
53
|
+
"template": "Set the DAI allowance {holder} gives {spender} to all of it if allowed is true, to none if false (allowed: {allowed}). Signature expires: {expiry}."
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"at": "Permit",
|
|
58
|
+
"tag": "effect",
|
|
59
|
+
"args": {
|
|
60
|
+
"kind": "approve",
|
|
61
|
+
"irreversible": false
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"at": "Permit(0).holder",
|
|
66
|
+
"tag": "describe",
|
|
67
|
+
"args": {
|
|
68
|
+
"label": "Holder"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"at": "Permit(0).spender",
|
|
73
|
+
"tag": "describe",
|
|
74
|
+
"args": {
|
|
75
|
+
"label": "Spender"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"at": "Permit(0).allowed",
|
|
80
|
+
"tag": "describe",
|
|
81
|
+
"args": {
|
|
82
|
+
"label": "Allowed (true: all, false: none)"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"at": "Permit(0).expiry",
|
|
87
|
+
"tag": "timestamp",
|
|
88
|
+
"args": {
|
|
89
|
+
"unit": "s",
|
|
90
|
+
"epoch": "unix",
|
|
91
|
+
"threshold": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
|
92
|
+
"message": "Never",
|
|
93
|
+
"labels": {
|
|
94
|
+
"0": "Never"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"at": "Permit(0).expiry",
|
|
100
|
+
"tag": "describe",
|
|
101
|
+
"args": {
|
|
102
|
+
"label": "Signature expires"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"at": "Permit(0).nonce",
|
|
107
|
+
"tag": "describe",
|
|
108
|
+
"args": {
|
|
109
|
+
"label": "Nonce"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "candid-profile",
|
|
3
|
+
"format_version": 0,
|
|
4
|
+
"kind": "pack",
|
|
5
|
+
"name": "erc2612",
|
|
6
|
+
"origin": "pack",
|
|
7
|
+
"language": "en",
|
|
8
|
+
"description": "Standard pack for EIP-2612 permits on EVM chains (spec section 15.9, experimental): the signed `Permit` message that sets an ERC-20 allowance, and the `permit` function that submits one. Applies to a contract that has every function of `binds.abi` with the same selector, outputs and kind of call, `decimals()` and `symbol()` included, since the amounts read them. A signing request matches the `Permit` message by its EIP-712 type hash, and its verifying contract is the token, so `query:` refs are calls to that token. The domain's name and version are each token's own, so the pack names neither.",
|
|
9
|
+
"binds": {
|
|
10
|
+
"standard": "ERC-2612",
|
|
11
|
+
"spec_url": "https://eips.ethereum.org/EIPS/eip-2612",
|
|
12
|
+
"abi": [
|
|
13
|
+
"function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)",
|
|
14
|
+
"function nonces(address owner) view returns (uint256)",
|
|
15
|
+
"function DOMAIN_SEPARATOR() view returns (bytes32)",
|
|
16
|
+
"function decimals() view returns (uint8)",
|
|
17
|
+
"function symbol() view returns (string)"
|
|
18
|
+
],
|
|
19
|
+
"eip712": {
|
|
20
|
+
"types": {
|
|
21
|
+
"Permit": [
|
|
22
|
+
{
|
|
23
|
+
"name": "owner",
|
|
24
|
+
"type": "address"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "spender",
|
|
28
|
+
"type": "address"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "value",
|
|
32
|
+
"type": "uint256"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "nonce",
|
|
36
|
+
"type": "uint256"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "deadline",
|
|
40
|
+
"type": "uint256"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"annotations": [
|
|
47
|
+
{
|
|
48
|
+
"at": "Permit",
|
|
49
|
+
"tag": "intent",
|
|
50
|
+
"args": {
|
|
51
|
+
"title": "Permit token spending",
|
|
52
|
+
"template": "Allow {spender} to spend up to {value} from {owner}. Signature expires: {deadline}."
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"at": "Permit",
|
|
57
|
+
"tag": "effect",
|
|
58
|
+
"args": {
|
|
59
|
+
"kind": "approve",
|
|
60
|
+
"irreversible": false
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"at": "Permit(0).value",
|
|
65
|
+
"tag": "amount",
|
|
66
|
+
"args": {
|
|
67
|
+
"decimals": {
|
|
68
|
+
"from": "query:decimals"
|
|
69
|
+
},
|
|
70
|
+
"symbol": {
|
|
71
|
+
"from": "query:symbol"
|
|
72
|
+
},
|
|
73
|
+
"threshold": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"at": "Permit(0).value",
|
|
78
|
+
"tag": "describe",
|
|
79
|
+
"args": {
|
|
80
|
+
"label": "Amount"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"at": "Permit(0).deadline",
|
|
85
|
+
"tag": "timestamp",
|
|
86
|
+
"args": {
|
|
87
|
+
"unit": "s",
|
|
88
|
+
"epoch": "unix",
|
|
89
|
+
"threshold": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
|
90
|
+
"message": "Never"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"at": "Permit(0).deadline",
|
|
95
|
+
"tag": "describe",
|
|
96
|
+
"args": {
|
|
97
|
+
"label": "Signature expires"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"at": "Permit(0).owner",
|
|
102
|
+
"tag": "describe",
|
|
103
|
+
"args": {
|
|
104
|
+
"label": "Owner"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"at": "Permit(0).spender",
|
|
109
|
+
"tag": "describe",
|
|
110
|
+
"args": {
|
|
111
|
+
"label": "Spender"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"at": "Permit(0).nonce",
|
|
116
|
+
"tag": "describe",
|
|
117
|
+
"args": {
|
|
118
|
+
"label": "Nonce"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"at": "permit",
|
|
123
|
+
"tag": "intent",
|
|
124
|
+
"args": {
|
|
125
|
+
"title": "Submit a token permit",
|
|
126
|
+
"template": "Set {spender}'s allowance from {owner} to {value} with {owner}'s signature. Signature expires: {deadline}."
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"at": "permit",
|
|
131
|
+
"tag": "effect",
|
|
132
|
+
"args": {
|
|
133
|
+
"kind": "approve",
|
|
134
|
+
"irreversible": false
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"at": "permit(0).value",
|
|
139
|
+
"tag": "amount",
|
|
140
|
+
"args": {
|
|
141
|
+
"decimals": {
|
|
142
|
+
"from": "query:decimals"
|
|
143
|
+
},
|
|
144
|
+
"symbol": {
|
|
145
|
+
"from": "query:symbol"
|
|
146
|
+
},
|
|
147
|
+
"threshold": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"at": "permit(0).value",
|
|
152
|
+
"tag": "describe",
|
|
153
|
+
"args": {
|
|
154
|
+
"label": "Amount"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"at": "permit(0).deadline",
|
|
159
|
+
"tag": "timestamp",
|
|
160
|
+
"args": {
|
|
161
|
+
"unit": "s",
|
|
162
|
+
"epoch": "unix",
|
|
163
|
+
"threshold": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
|
164
|
+
"message": "Never"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"at": "permit(0).deadline",
|
|
169
|
+
"tag": "describe",
|
|
170
|
+
"args": {
|
|
171
|
+
"label": "Signature expires"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"at": "permit(0).owner",
|
|
176
|
+
"tag": "describe",
|
|
177
|
+
"args": {
|
|
178
|
+
"label": "Owner"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"at": "permit(0).spender",
|
|
183
|
+
"tag": "describe",
|
|
184
|
+
"args": {
|
|
185
|
+
"label": "Spender"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"at": "permit(0).v",
|
|
190
|
+
"tag": "describe",
|
|
191
|
+
"args": {
|
|
192
|
+
"label": "Signature v"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|