@avow-finance/sdk 0.0.0-stage → 0.2.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/LICENSE +201 -0
- package/README.md +122 -2
- package/dist/agent-entry.d.ts +15 -0
- package/dist/agent-entry.d.ts.map +1 -0
- package/dist/agent-entry.js +11 -0
- package/dist/agent-entry.js.map +1 -0
- package/dist/agent-key.d.ts +34 -0
- package/dist/agent-key.d.ts.map +1 -0
- package/dist/agent-key.js +33 -0
- package/dist/agent-key.js.map +1 -0
- package/dist/agent.d.ts +261 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +493 -0
- package/dist/agent.js.map +1 -0
- package/dist/avow-api.d.ts +78 -0
- package/dist/avow-api.d.ts.map +1 -0
- package/dist/avow-api.js +2 -0
- package/dist/avow-api.js.map +1 -0
- package/dist/contest.d.ts +135 -0
- package/dist/contest.d.ts.map +1 -0
- package/dist/contest.js +186 -0
- package/dist/contest.js.map +1 -0
- package/dist/http.d.ts +161 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +311 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/job/accept.d.ts +84 -0
- package/dist/job/accept.d.ts.map +1 -0
- package/dist/job/accept.js +136 -0
- package/dist/job/accept.js.map +1 -0
- package/dist/job/customer.d.ts +43 -0
- package/dist/job/customer.d.ts.map +1 -0
- package/dist/job/customer.js +83 -0
- package/dist/job/customer.js.map +1 -0
- package/dist/job/quote.d.ts +34 -0
- package/dist/job/quote.d.ts.map +1 -0
- package/dist/job/quote.js +37 -0
- package/dist/job/quote.js.map +1 -0
- package/dist/lock.d.ts +269 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +283 -0
- package/dist/lock.js.map +1 -0
- package/dist/moderato.d.ts +27 -0
- package/dist/moderato.d.ts.map +1 -0
- package/dist/moderato.js +34 -0
- package/dist/moderato.js.map +1 -0
- package/dist/node/cli.d.ts +3 -0
- package/dist/node/cli.d.ts.map +1 -0
- package/dist/node/cli.js +346 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/connect.d.ts +15 -0
- package/dist/node/connect.d.ts.map +1 -0
- package/dist/node/connect.js +91 -0
- package/dist/node/connect.js.map +1 -0
- package/dist/node/eval.d.ts +3 -0
- package/dist/node/eval.d.ts.map +1 -0
- package/dist/node/eval.js +67 -0
- package/dist/node/eval.js.map +1 -0
- package/dist/node/first-run.d.ts +50 -0
- package/dist/node/first-run.d.ts.map +1 -0
- package/dist/node/first-run.js +149 -0
- package/dist/node/first-run.js.map +1 -0
- package/dist/node/job.d.ts +50 -0
- package/dist/node/job.d.ts.map +1 -0
- package/dist/node/job.js +176 -0
- package/dist/node/job.js.map +1 -0
- package/dist/node/mailbox.d.ts +19 -0
- package/dist/node/mailbox.d.ts.map +1 -0
- package/dist/node/mailbox.js +81 -0
- package/dist/node/mailbox.js.map +1 -0
- package/dist/node/mcp.d.ts +74 -0
- package/dist/node/mcp.d.ts.map +1 -0
- package/dist/node/mcp.js +367 -0
- package/dist/node/mcp.js.map +1 -0
- package/dist/node/platform.d.ts +35 -0
- package/dist/node/platform.d.ts.map +1 -0
- package/dist/node/platform.js +102 -0
- package/dist/node/platform.js.map +1 -0
- package/dist/node/runner-session.d.ts +41 -0
- package/dist/node/runner-session.d.ts.map +1 -0
- package/dist/node/runner-session.js +100 -0
- package/dist/node/runner-session.js.map +1 -0
- package/dist/node/runner.d.ts +63 -0
- package/dist/node/runner.d.ts.map +1 -0
- package/dist/node/runner.js +341 -0
- package/dist/node/runner.js.map +1 -0
- package/dist/node/service-child.d.ts +2 -0
- package/dist/node/service-child.d.ts.map +1 -0
- package/dist/node/service-child.js +40 -0
- package/dist/node/service-child.js.map +1 -0
- package/dist/node/service-excerpt.d.ts +21 -0
- package/dist/node/service-excerpt.d.ts.map +1 -0
- package/dist/node/service-excerpt.js +32 -0
- package/dist/node/service-excerpt.js.map +1 -0
- package/dist/node/service-process.d.ts +12 -0
- package/dist/node/service-process.d.ts.map +1 -0
- package/dist/node/service-process.js +132 -0
- package/dist/node/service-process.js.map +1 -0
- package/dist/node/session-input.d.ts +12 -0
- package/dist/node/session-input.d.ts.map +1 -0
- package/dist/node/session-input.js +42 -0
- package/dist/node/session-input.js.map +1 -0
- package/dist/node/session-view.d.ts +20 -0
- package/dist/node/session-view.d.ts.map +1 -0
- package/dist/node/session-view.js +198 -0
- package/dist/node/session-view.js.map +1 -0
- package/dist/node-agent.d.ts +2 -0
- package/dist/node-agent.d.ts.map +1 -0
- package/dist/node-agent.js +6 -0
- package/dist/node-agent.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +9 -0
- package/dist/node.js.map +1 -0
- package/dist/sandbox/agent.d.ts +187 -0
- package/dist/sandbox/agent.d.ts.map +1 -0
- package/dist/sandbox/agent.js +468 -0
- package/dist/sandbox/agent.js.map +1 -0
- package/dist/sandbox/business-store.d.ts +19 -0
- package/dist/sandbox/business-store.d.ts.map +1 -0
- package/dist/sandbox/business-store.js +19 -0
- package/dist/sandbox/business-store.js.map +1 -0
- package/dist/sandbox/business.d.ts +70 -0
- package/dist/sandbox/business.d.ts.map +1 -0
- package/dist/sandbox/business.js +115 -0
- package/dist/sandbox/business.js.map +1 -0
- package/dist/sandbox/connect.d.ts +64 -0
- package/dist/sandbox/connect.d.ts.map +1 -0
- package/dist/sandbox/connect.js +182 -0
- package/dist/sandbox/connect.js.map +1 -0
- package/dist/sandbox/deployment.d.ts +14 -0
- package/dist/sandbox/deployment.d.ts.map +1 -0
- package/dist/sandbox/deployment.js +38 -0
- package/dist/sandbox/deployment.js.map +1 -0
- package/dist/sandbox/keys.d.ts +45 -0
- package/dist/sandbox/keys.d.ts.map +1 -0
- package/dist/sandbox/keys.js +132 -0
- package/dist/sandbox/keys.js.map +1 -0
- package/dist/sandbox/mailbox.d.ts +90 -0
- package/dist/sandbox/mailbox.d.ts.map +1 -0
- package/dist/sandbox/mailbox.js +400 -0
- package/dist/sandbox/mailbox.js.map +1 -0
- package/dist/sandbox/mandate.d.ts +84 -0
- package/dist/sandbox/mandate.d.ts.map +1 -0
- package/dist/sandbox/mandate.js +107 -0
- package/dist/sandbox/mandate.js.map +1 -0
- package/dist/sandbox/namespace.d.ts +16 -0
- package/dist/sandbox/namespace.d.ts.map +1 -0
- package/dist/sandbox/namespace.js +16 -0
- package/dist/sandbox/namespace.js.map +1 -0
- package/dist/sandbox/session.d.ts +60 -0
- package/dist/sandbox/session.d.ts.map +1 -0
- package/dist/sandbox/session.js +94 -0
- package/dist/sandbox/session.js.map +1 -0
- package/dist/sandbox/setup.d.ts +136 -0
- package/dist/sandbox/setup.d.ts.map +1 -0
- package/dist/sandbox/setup.js +490 -0
- package/dist/sandbox/setup.js.map +1 -0
- package/dist/sandbox/store.d.ts +69 -0
- package/dist/sandbox/store.d.ts.map +1 -0
- package/dist/sandbox/store.js +115 -0
- package/dist/sandbox/store.js.map +1 -0
- package/dist/sandbox/supplier-key.d.ts +73 -0
- package/dist/sandbox/supplier-key.d.ts.map +1 -0
- package/dist/sandbox/supplier-key.js +180 -0
- package/dist/sandbox/supplier-key.js.map +1 -0
- package/dist/sandbox/suppliers.d.ts +7 -0
- package/dist/sandbox/suppliers.d.ts.map +1 -0
- package/dist/sandbox/suppliers.js +29 -0
- package/dist/sandbox/suppliers.js.map +1 -0
- package/dist/sandbox/terms.d.ts +32 -0
- package/dist/sandbox/terms.d.ts.map +1 -0
- package/dist/sandbox/terms.js +58 -0
- package/dist/sandbox/terms.js.map +1 -0
- package/dist/sandbox/vault.d.ts +24 -0
- package/dist/sandbox/vault.d.ts.map +1 -0
- package/dist/sandbox/vault.js +54 -0
- package/dist/sandbox/vault.js.map +1 -0
- package/dist/send.d.ts +122 -0
- package/dist/send.d.ts.map +1 -0
- package/dist/send.js +328 -0
- package/dist/send.js.map +1 -0
- package/dist/service-entry.d.ts +6 -0
- package/dist/service-entry.d.ts.map +1 -0
- package/dist/service-entry.js +6 -0
- package/dist/service-entry.js.map +1 -0
- package/dist/session/anthropic.d.ts +17 -0
- package/dist/session/anthropic.d.ts.map +1 -0
- package/dist/session/anthropic.js +215 -0
- package/dist/session/anthropic.js.map +1 -0
- package/dist/session/charge.d.ts +13 -0
- package/dist/session/charge.d.ts.map +1 -0
- package/dist/session/charge.js +33 -0
- package/dist/session/charge.js.map +1 -0
- package/dist/session/data.d.ts +8 -0
- package/dist/session/data.d.ts.map +1 -0
- package/dist/session/data.js +20 -0
- package/dist/session/data.js.map +1 -0
- package/dist/session/eval.d.ts +41 -0
- package/dist/session/eval.d.ts.map +1 -0
- package/dist/session/eval.js +281 -0
- package/dist/session/eval.js.map +1 -0
- package/dist/session/executor.d.ts +80 -0
- package/dist/session/executor.d.ts.map +1 -0
- package/dist/session/executor.js +381 -0
- package/dist/session/executor.js.map +1 -0
- package/dist/session/fixture-world.d.ts +29 -0
- package/dist/session/fixture-world.d.ts.map +1 -0
- package/dist/session/fixture-world.js +708 -0
- package/dist/session/fixture-world.js.map +1 -0
- package/dist/session/live-world.d.ts +22 -0
- package/dist/session/live-world.d.ts.map +1 -0
- package/dist/session/live-world.js +329 -0
- package/dist/session/live-world.js.map +1 -0
- package/dist/session/ollama.d.ts +29 -0
- package/dist/session/ollama.d.ts.map +1 -0
- package/dist/session/ollama.js +177 -0
- package/dist/session/ollama.js.map +1 -0
- package/dist/session/provider.d.ts +79 -0
- package/dist/session/provider.d.ts.map +1 -0
- package/dist/session/provider.js +19 -0
- package/dist/session/provider.js.map +1 -0
- package/dist/session/scripted.d.ts +45 -0
- package/dist/session/scripted.d.ts.map +1 -0
- package/dist/session/scripted.js +236 -0
- package/dist/session/scripted.js.map +1 -0
- package/dist/session/selection.d.ts +37 -0
- package/dist/session/selection.d.ts.map +1 -0
- package/dist/session/selection.js +104 -0
- package/dist/session/selection.js.map +1 -0
- package/dist/session/service-check.d.ts +48 -0
- package/dist/session/service-check.d.ts.map +1 -0
- package/dist/session/service-check.js +86 -0
- package/dist/session/service-check.js.map +1 -0
- package/dist/session/service.d.ts +128 -0
- package/dist/session/service.d.ts.map +1 -0
- package/dist/session/service.js +150 -0
- package/dist/session/service.js.map +1 -0
- package/dist/session/session.d.ts +95 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +312 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/toolbox.d.ts +69 -0
- package/dist/session/toolbox.d.ts.map +1 -0
- package/dist/session/toolbox.js +391 -0
- package/dist/session/toolbox.js.map +1 -0
- package/dist/session/tools.d.ts +45 -0
- package/dist/session/tools.d.ts.map +1 -0
- package/dist/session/tools.js +137 -0
- package/dist/session/tools.js.map +1 -0
- package/dist/session/world.d.ts +188 -0
- package/dist/session/world.d.ts.map +1 -0
- package/dist/session/world.js +2 -0
- package/dist/session/world.js.map +1 -0
- package/dist/sign.d.ts +19 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign.js +33 -0
- package/dist/sign.js.map +1 -0
- package/dist/supplier.d.ts +41 -0
- package/dist/supplier.d.ts.map +1 -0
- package/dist/supplier.js +57 -0
- package/dist/supplier.js.map +1 -0
- package/package.json +56 -3
package/dist/lock.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { approvalTypedData, CONTEST_REASONS, contestStatementHash, SIDE_CODES, } from '@avow-finance/spec';
|
|
2
|
+
import { FACTORY_ABI } from '@avow-finance/verifier';
|
|
3
|
+
import { encodeFunctionData, toFunctionSelector, } from 'viem';
|
|
4
|
+
import { readContract } from 'viem/actions';
|
|
5
|
+
import { Abis } from 'viem/tempo';
|
|
6
|
+
/**
|
|
7
|
+
* The lock function an agent's key calls to fund a reserve, as the testnet lock declares it. The
|
|
8
|
+
* lock is unaudited testnet code, and a new factory can change this interface. Knowing it grants
|
|
9
|
+
* nothing, since on each call the lock checks Avow's signature over every field of the approval,
|
|
10
|
+
* the calling account and key, the supplier, the caps and the expiry.
|
|
11
|
+
*/
|
|
12
|
+
export const RESERVE_ABI = [
|
|
13
|
+
{
|
|
14
|
+
type: 'function',
|
|
15
|
+
name: 'reserve',
|
|
16
|
+
inputs: [
|
|
17
|
+
{
|
|
18
|
+
name: 'a',
|
|
19
|
+
type: 'tuple',
|
|
20
|
+
components: [
|
|
21
|
+
{ name: 'commitmentId', type: 'bytes32' },
|
|
22
|
+
{ name: 'side', type: 'uint8' },
|
|
23
|
+
{ name: 'token', type: 'address' },
|
|
24
|
+
{ name: 'amount', type: 'uint256' },
|
|
25
|
+
{ name: 'supplier', type: 'address' },
|
|
26
|
+
{ name: 'supplierSigner', type: 'address' },
|
|
27
|
+
{ name: 'payee', type: 'address' },
|
|
28
|
+
{ name: 'freeCancelBy', type: 'uint64' },
|
|
29
|
+
{ name: 'acceptBy', type: 'uint64' },
|
|
30
|
+
{ name: 'chargeDeadline', type: 'uint64' },
|
|
31
|
+
{ name: 'releaseDate', type: 'uint64' },
|
|
32
|
+
{ name: 'contestWindow', type: 'uint64' },
|
|
33
|
+
{
|
|
34
|
+
name: 'charges',
|
|
35
|
+
type: 'tuple[]',
|
|
36
|
+
components: [
|
|
37
|
+
{ name: 'kind', type: 'uint8' },
|
|
38
|
+
{ name: 'most', type: 'uint256' },
|
|
39
|
+
{ name: 'earliest', type: 'uint64' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{ name: 'day90SupplierShareBps', type: 'uint16' },
|
|
43
|
+
{ name: 'arbiter', type: 'address' },
|
|
44
|
+
{ name: 'termsHash', type: 'bytes32' },
|
|
45
|
+
{ name: 'mandateHash', type: 'bytes32' },
|
|
46
|
+
{ name: 'capPerCommitment', type: 'uint256' },
|
|
47
|
+
{ name: 'capOpenReserves', type: 'uint256' },
|
|
48
|
+
{ name: 'fundingKey', type: 'address' },
|
|
49
|
+
{ name: 'nonce', type: 'uint256' },
|
|
50
|
+
{ name: 'expiry', type: 'uint64' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{ name: 'avowSignature', type: 'bytes' },
|
|
54
|
+
],
|
|
55
|
+
outputs: [],
|
|
56
|
+
stateMutability: 'nonpayable',
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* The selector of `reserve`, the only lock function an agent's key may call. `agentKeyTerms`
|
|
61
|
+
* takes it as the key's one lock selector.
|
|
62
|
+
*/
|
|
63
|
+
export const RESERVE_SELECTOR = toFunctionSelector(RESERVE_ABI[0]);
|
|
64
|
+
/**
|
|
65
|
+
* The calls a business account's root key makes on its own lock and on the factory, as the testnet
|
|
66
|
+
* contracts declare them. Approving a supplier lets an agent reserve for it, and only the account's
|
|
67
|
+
* root key can do it. Cancelling before free cancellation ends takes a reserve back in full, and
|
|
68
|
+
* contesting a charge pauses it until someone rules.
|
|
69
|
+
*/
|
|
70
|
+
export const ADMINISTRATOR_ABI = [
|
|
71
|
+
{
|
|
72
|
+
type: 'function',
|
|
73
|
+
name: 'approveSupplier',
|
|
74
|
+
inputs: [{ name: 'supplier', type: 'address' }],
|
|
75
|
+
outputs: [],
|
|
76
|
+
stateMutability: 'nonpayable',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'function',
|
|
80
|
+
name: 'removeSupplier',
|
|
81
|
+
inputs: [{ name: 'supplier', type: 'address' }],
|
|
82
|
+
outputs: [],
|
|
83
|
+
stateMutability: 'nonpayable',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'function',
|
|
87
|
+
name: 'approvedSupplier',
|
|
88
|
+
inputs: [{ name: 'supplier', type: 'address' }],
|
|
89
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
90
|
+
stateMutability: 'view',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'function',
|
|
94
|
+
name: 'cancelFree',
|
|
95
|
+
inputs: [
|
|
96
|
+
{ name: 'commitmentId', type: 'bytes32' },
|
|
97
|
+
{ name: 'side', type: 'uint8' },
|
|
98
|
+
],
|
|
99
|
+
outputs: [],
|
|
100
|
+
stateMutability: 'nonpayable',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'function',
|
|
104
|
+
name: 'contest',
|
|
105
|
+
inputs: [
|
|
106
|
+
{ name: 'commitmentId', type: 'bytes32' },
|
|
107
|
+
{ name: 'side', type: 'uint8' },
|
|
108
|
+
{ name: 'reportNumber', type: 'uint8' },
|
|
109
|
+
{ name: 'reasonCode', type: 'uint16' },
|
|
110
|
+
{ name: 'statementHash', type: 'bytes32' },
|
|
111
|
+
],
|
|
112
|
+
outputs: [],
|
|
113
|
+
stateMutability: 'nonpayable',
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* The lock factory's functions. The verifier defines them once, and the SDK passes the same
|
|
118
|
+
* definition on, so an agent and a supplier never read the factory through two different ABIs.
|
|
119
|
+
*/
|
|
120
|
+
export { FACTORY_ABI };
|
|
121
|
+
/**
|
|
122
|
+
* The lock's running total of what each mandate's open reserves hold. The lock refuses a reserve
|
|
123
|
+
* that would take it above the cap on open reserves that Avow's approval carries, and Avow's
|
|
124
|
+
* reserve check reads the same total before it approves one.
|
|
125
|
+
*/
|
|
126
|
+
export const OPEN_RESERVES_ABI = [
|
|
127
|
+
{
|
|
128
|
+
type: 'function',
|
|
129
|
+
name: 'openReserves',
|
|
130
|
+
inputs: [{ name: 'mandateHash', type: 'bytes32' }],
|
|
131
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
132
|
+
stateMutability: 'view',
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
/** What the lock holds in open reserves under one mandate, in the token's base units. */
|
|
136
|
+
export function readOpenReserves(client, lock, mandateHash) {
|
|
137
|
+
return readContract(client, {
|
|
138
|
+
address: lock,
|
|
139
|
+
abi: OPEN_RESERVES_ABI,
|
|
140
|
+
functionName: 'openReserves',
|
|
141
|
+
args: [mandateHash],
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The two calls that fund a reserve in one transaction. The first approves the lock to pull the
|
|
146
|
+
* approval's amount of its token, and the second calls `reserve` with Avow's approval and
|
|
147
|
+
* signature.
|
|
148
|
+
*/
|
|
149
|
+
export function reserveCalls(approval, d) {
|
|
150
|
+
const a = approval.message;
|
|
151
|
+
return [
|
|
152
|
+
{
|
|
153
|
+
to: a.token,
|
|
154
|
+
data: encodeFunctionData({
|
|
155
|
+
abi: Abis.tip20,
|
|
156
|
+
functionName: 'approve',
|
|
157
|
+
args: [d.verifyingContract, a.amount],
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
to: d.verifyingContract,
|
|
162
|
+
data: encodeFunctionData({
|
|
163
|
+
abi: RESERVE_ABI,
|
|
164
|
+
functionName: 'reserve',
|
|
165
|
+
args: [approvalTypedData(a, d).message, approval.signature],
|
|
166
|
+
}),
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
/** The call that creates a business account's lock from the factory. */
|
|
171
|
+
export function createLockCall(factory, account) {
|
|
172
|
+
return {
|
|
173
|
+
to: factory,
|
|
174
|
+
data: encodeFunctionData({ abi: FACTORY_ABI, functionName: 'createLock', args: [account] }),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** The call, from the business account's root key, that lets its agents reserve for a supplier. */
|
|
178
|
+
export function approveSupplierCall(lock, supplier) {
|
|
179
|
+
return {
|
|
180
|
+
to: lock,
|
|
181
|
+
data: encodeFunctionData({
|
|
182
|
+
abi: ADMINISTRATOR_ABI,
|
|
183
|
+
functionName: 'approveSupplier',
|
|
184
|
+
args: [supplier],
|
|
185
|
+
}),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The call, from the business account's root key, that stops its agents reserving for a supplier.
|
|
190
|
+
* A commitment already reserved for that supplier stays as it is.
|
|
191
|
+
*/
|
|
192
|
+
export function removeSupplierCall(lock, supplier) {
|
|
193
|
+
return {
|
|
194
|
+
to: lock,
|
|
195
|
+
data: encodeFunctionData({
|
|
196
|
+
abi: ADMINISTRATOR_ABI,
|
|
197
|
+
functionName: 'removeSupplier',
|
|
198
|
+
args: [supplier],
|
|
199
|
+
}),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The call, from the business account's root key, that cancels a commitment on the lock before
|
|
204
|
+
* free cancellation ends and gives the whole reserve back. It cancels the buyer's side, the only
|
|
205
|
+
* side a lock holds a reserve for in this release. Until then Avow refuses to record a
|
|
206
|
+
* cancellation, with `commitment.cancel_on_lock`, since the business cancels on the lock without
|
|
207
|
+
* anyone else's signature.
|
|
208
|
+
*/
|
|
209
|
+
export function cancelFreeCall(lock, commitmentId) {
|
|
210
|
+
return {
|
|
211
|
+
to: lock,
|
|
212
|
+
data: encodeFunctionData({
|
|
213
|
+
abi: ADMINISTRATOR_ABI,
|
|
214
|
+
functionName: 'cancelFree',
|
|
215
|
+
args: [commitmentId, SIDE_CODES.buyer],
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The call, from the business account's root key, that contests the charge or report a statement
|
|
221
|
+
* names. It carries the statement's reason code and its hash, which the lock logs in its `Paused`
|
|
222
|
+
* event, and throws on a statement the spec's format refuses.
|
|
223
|
+
*/
|
|
224
|
+
export function contestCall(lock, statement) {
|
|
225
|
+
return {
|
|
226
|
+
to: lock,
|
|
227
|
+
data: encodeFunctionData({
|
|
228
|
+
abi: ADMINISTRATOR_ABI,
|
|
229
|
+
functionName: 'contest',
|
|
230
|
+
args: [
|
|
231
|
+
statement.commitmentId,
|
|
232
|
+
SIDE_CODES[statement.side],
|
|
233
|
+
statement.reportNumber,
|
|
234
|
+
CONTEST_REASONS[statement.reason].code,
|
|
235
|
+
contestStatementHash(statement),
|
|
236
|
+
],
|
|
237
|
+
}),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Whether the lock takes `cancelFreeCall` for a commitment at `now`, by the chain's clock. It takes
|
|
242
|
+
* it for a reserve the supplier hasn't accepted, or one accepted with no report standing, until
|
|
243
|
+
* free cancellation ends, whatever the agent's mandate permits.
|
|
244
|
+
*/
|
|
245
|
+
export function cancelsFree(held, now) {
|
|
246
|
+
const open = held.state === 'reserved' || (held.state === 'accepted' && !held.hasReport);
|
|
247
|
+
return open && now < held.freeCancelBy;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The lock's `trigger`, as the testnet lock declares it, with the error it reverts with when no
|
|
251
|
+
* step is due. It takes whichever step is due for one side of a commitment once a deadline has
|
|
252
|
+
* passed. It returns a reserve the supplier never accepted, releases a kept reserve at its release
|
|
253
|
+
* date, times out a charge report Avow didn't confirm or refer in time, pays a confirmed charge
|
|
254
|
+
* once its contest window closes and applies a posted ruling once its delay has passed. At day 90
|
|
255
|
+
* it resolves a paused charge nobody ruled on, paying a confirmed charge at the day-90 share and
|
|
256
|
+
* returning an unconfirmed one to the business in full. Anyone can send it, since the lock pays
|
|
257
|
+
* only the parties it recorded.
|
|
258
|
+
*/
|
|
259
|
+
export const TRIGGER_ABI = [
|
|
260
|
+
{
|
|
261
|
+
type: 'function',
|
|
262
|
+
name: 'trigger',
|
|
263
|
+
inputs: [
|
|
264
|
+
{ name: 'commitmentId', type: 'bytes32' },
|
|
265
|
+
{ name: 'side', type: 'uint8' },
|
|
266
|
+
],
|
|
267
|
+
outputs: [],
|
|
268
|
+
stateMutability: 'nonpayable',
|
|
269
|
+
},
|
|
270
|
+
{ type: 'error', name: 'NothingDue', inputs: [] },
|
|
271
|
+
];
|
|
272
|
+
/** The call that takes the step due for one side of a commitment, from any account. */
|
|
273
|
+
export function triggerCall(lock, commitmentId, side) {
|
|
274
|
+
return {
|
|
275
|
+
to: lock,
|
|
276
|
+
data: encodeFunctionData({
|
|
277
|
+
abi: TRIGGER_ABI,
|
|
278
|
+
functionName: 'trigger',
|
|
279
|
+
args: [commitmentId, SIDE_CODES[side]],
|
|
280
|
+
}),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=lock.js.map
|
package/dist/lock.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../src/lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAEf,oBAAoB,EACpB,UAAU,GAGX,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAsB,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAIL,kBAAkB,EAGlB,kBAAkB,GACnB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE;oBACzC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;oBAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;oBAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;oBACnC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;oBACrC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;oBAC3C,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;oBAClC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxC,EAAE,IAAI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;IACtE,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,kBAAkB,CAAC;YACvB,GAAG,EAAE,WAAW;YAChB,YAAY,EAAE,SAAS;YACvB,IAAI,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;SACvC,CAAC;KACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type RailToken } from '@avow-finance/spec';
|
|
2
|
+
import { type Address, type Chain, type Hex, type HttpTransport, type PublicClient } from 'viem';
|
|
3
|
+
/** Moderato's public RPC. Moderato is Tempo's testnet, where every Avow deployment so far runs. */
|
|
4
|
+
export declare const MODERATO_RPC_URL = "https://rpc.moderato.tempo.xyz";
|
|
5
|
+
/**
|
|
6
|
+
* Avow's lock factory on Moderato. The SDK trusts a lock as Avow's only when this factory made it,
|
|
7
|
+
* whatever a deployment's published settings say.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MODERATO_FACTORY: Address;
|
|
10
|
+
/** The block that factory was created in, the first with its code, so no lock it made is older. */
|
|
11
|
+
export declare const MODERATO_FACTORY_CREATED_IN = 41801818n;
|
|
12
|
+
/** A transaction's page in Moderato's explorer. */
|
|
13
|
+
export declare const moderatoTransactionUrl: (hash: Hex) => string;
|
|
14
|
+
/** AlphaUSD, which pays Moderato's fees and comes from its faucet. */
|
|
15
|
+
export declare const MODERATO_FEE_TOKEN: Address;
|
|
16
|
+
/**
|
|
17
|
+
* A client for Moderato that pays fees in AlphaUSD, as `createAgent`, `sendOwn` and the
|
|
18
|
+
* verifier's `tempoChainReader` take it. It reads through `rpcUrl`, the public RPC by default, and
|
|
19
|
+
* tries a failed request three more times.
|
|
20
|
+
*/
|
|
21
|
+
export declare function moderatoClient(rpcUrl?: string): PublicClient<HttpTransport, Chain>;
|
|
22
|
+
/**
|
|
23
|
+
* A USD token on Moderato as a `RailToken`, the form the SDK and the verifier take a reserve token
|
|
24
|
+
* in. A USD token on Tempo has 6 decimals, so its base units equal the micros terms count in.
|
|
25
|
+
*/
|
|
26
|
+
export declare function moderatoUsdToken(token: Address): RailToken;
|
|
27
|
+
//# sourceMappingURL=moderato.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moderato.d.ts","sourceRoot":"","sources":["../src/moderato.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,oBAAoB,CAAA;AACnE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EACR,KAAK,aAAa,EAElB,KAAK,YAAY,EAElB,MAAM,MAAM,CAAA;AAGb,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,mCAAmC,CAAA;AAEhE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAsD,CAAA;AAErF,mGAAmG;AACnG,eAAO,MAAM,2BAA2B,YAAc,CAAA;AAEtD,mDAAmD;AACnD,eAAO,MAAM,sBAAsB,SAAU,GAAG,KAAG,MACO,CAAA;AAE1D,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,EAAE,OAAsD,CAAA;AAEvF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,GAAE,MAAyB,GAChC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,CAIpC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAE1D"}
|
package/dist/moderato.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TEMPO_MODERATO } from '@avow-finance/spec';
|
|
2
|
+
import { createClient, http, publicActions, } from 'viem';
|
|
3
|
+
import { tempoModerato } from 'viem/chains';
|
|
4
|
+
/** Moderato's public RPC. Moderato is Tempo's testnet, where every Avow deployment so far runs. */
|
|
5
|
+
export const MODERATO_RPC_URL = 'https://rpc.moderato.tempo.xyz';
|
|
6
|
+
/**
|
|
7
|
+
* Avow's lock factory on Moderato. The SDK trusts a lock as Avow's only when this factory made it,
|
|
8
|
+
* whatever a deployment's published settings say.
|
|
9
|
+
*/
|
|
10
|
+
export const MODERATO_FACTORY = '0x8fa7177c84BE069df2a51F096ED28d5D661B8283';
|
|
11
|
+
/** The block that factory was created in, the first with its code, so no lock it made is older. */
|
|
12
|
+
export const MODERATO_FACTORY_CREATED_IN = 41801818n;
|
|
13
|
+
/** A transaction's page in Moderato's explorer. */
|
|
14
|
+
export const moderatoTransactionUrl = (hash) => `${tempoModerato.blockExplorers.default.url}/tx/${hash}`;
|
|
15
|
+
/** AlphaUSD, which pays Moderato's fees and comes from its faucet. */
|
|
16
|
+
export const MODERATO_FEE_TOKEN = '0x20C0000000000000000000000000000000000001';
|
|
17
|
+
/**
|
|
18
|
+
* A client for Moderato that pays fees in AlphaUSD, as `createAgent`, `sendOwn` and the
|
|
19
|
+
* verifier's `tempoChainReader` take it. It reads through `rpcUrl`, the public RPC by default, and
|
|
20
|
+
* tries a failed request three more times.
|
|
21
|
+
*/
|
|
22
|
+
export function moderatoClient(rpcUrl = MODERATO_RPC_URL) {
|
|
23
|
+
// Tempo's formatters and serializers travel on the chain object, whatever its static type.
|
|
24
|
+
const chain = tempoModerato.extend({ feeToken: MODERATO_FEE_TOKEN });
|
|
25
|
+
return createClient({ chain, transport: http(rpcUrl, { retryCount: 3 }) }).extend(publicActions);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A USD token on Moderato as a `RailToken`, the form the SDK and the verifier take a reserve token
|
|
29
|
+
* in. A USD token on Tempo has 6 decimals, so its base units equal the micros terms count in.
|
|
30
|
+
*/
|
|
31
|
+
export function moderatoUsdToken(token) {
|
|
32
|
+
return { rail: 'tempo', chainId: TEMPO_MODERATO, token, currency: 'USD', decimals: 6 };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=moderato.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moderato.js","sourceRoot":"","sources":["../src/moderato.ts"],"names":[],"mappings":"AAAA,OA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