@interest-protocol/blast-partners-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/README.md +8 -2
- package/dist/events.d.ts +89 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +105 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/reducer.d.ts +39 -0
- package/dist/reducer.d.ts.map +1 -0
- package/dist/reducer.js +105 -0
- package/dist/reducer.js.map +1 -0
- package/dist/state.d.ts +127 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +100 -0
- package/dist/state.js.map +1 -0
- package/dist/transactions.d.ts +129 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/transactions.js +214 -0
- package/dist/transactions.js.map +1 -0
- package/package.json +56 -4
- package/src/events.ts +160 -0
- package/src/index.ts +4 -0
- package/src/reducer.ts +162 -0
- package/src/state.ts +166 -0
- package/src/transactions.ts +327 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { AdminDeployment } from "@interest-protocol/blast-admin-sdk/transactions";
|
|
2
|
+
import { AdminCalls } from "@interest-protocol/blast-admin-sdk/transactions";
|
|
3
|
+
import type { SharedObjectReference } from "@interest-protocol/blast-core/sui";
|
|
4
|
+
import type { TransactionObjectArgument, TransactionObjectInput, TransactionResult } from "@mysten/sui/transactions";
|
|
5
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
6
|
+
/** The canonical `blast_partners` package (immutability deferred) and the ACL its `PartnerAdmin` signs in to. */
|
|
7
|
+
export type PartnersDeployment = {
|
|
8
|
+
packageId: string;
|
|
9
|
+
admin: AdminDeployment;
|
|
10
|
+
};
|
|
11
|
+
/** `blast_partners::blast_partners` calls. */
|
|
12
|
+
export declare class PartnersCalls {
|
|
13
|
+
#private;
|
|
14
|
+
readonly deployment: PartnersDeployment;
|
|
15
|
+
readonly admin: AdminCalls;
|
|
16
|
+
constructor(deployment: PartnersDeployment);
|
|
17
|
+
/** The `PartnerAdmin` role type, for `AdminCalls.grantRole`. */
|
|
18
|
+
roleType(): string;
|
|
19
|
+
/** This PTB's `AdminWitness<PartnerAdmin>`. */
|
|
20
|
+
signIn(options: {
|
|
21
|
+
adminCap: TransactionObjectInput;
|
|
22
|
+
}): (tx: Transaction) => TransactionObjectArgument;
|
|
23
|
+
/** `new_cap`: anyone may mint one; it controls nothing until a partner names it. */
|
|
24
|
+
newCap(): (tx: Transaction) => TransactionResult;
|
|
25
|
+
/**
|
|
26
|
+
* `register` (`PartnerAdmin`): shares a partner managed by the cap
|
|
27
|
+
* `capId`, its share and cap in force at once.
|
|
28
|
+
*/
|
|
29
|
+
register(options: {
|
|
30
|
+
adminWitness: TransactionObjectInput;
|
|
31
|
+
capId: string;
|
|
32
|
+
recipient: string;
|
|
33
|
+
shareBps: bigint;
|
|
34
|
+
}): (tx: Transaction) => void;
|
|
35
|
+
/**
|
|
36
|
+
* `schedule_share` (`PartnerAdmin`): proposes the share, which `applyShare`
|
|
37
|
+
* applies once `PARTNER_DELAY_MS` has passed. A new proposal replaces a
|
|
38
|
+
* pending one and restarts the notice.
|
|
39
|
+
*/
|
|
40
|
+
scheduleShare(options: {
|
|
41
|
+
partner: SharedObjectReference<true>;
|
|
42
|
+
adminWitness: TransactionObjectInput;
|
|
43
|
+
shareBps: bigint;
|
|
44
|
+
}): (tx: Transaction) => void;
|
|
45
|
+
/**
|
|
46
|
+
* `schedule_cap` (`PartnerAdmin`): proposes moving the partner to the cap
|
|
47
|
+
* `capId`, which `applyCap` applies once `PARTNER_DELAY_MS` has passed.
|
|
48
|
+
*/
|
|
49
|
+
scheduleCap(options: {
|
|
50
|
+
partner: SharedObjectReference<true>;
|
|
51
|
+
adminWitness: TransactionObjectInput;
|
|
52
|
+
capId: string;
|
|
53
|
+
}): (tx: Transaction) => void;
|
|
54
|
+
/** `apply_share`: anyone applies the proposed share once its notice has passed. */
|
|
55
|
+
applyShare(options: {
|
|
56
|
+
partner: SharedObjectReference<true>;
|
|
57
|
+
}): (tx: Transaction) => void;
|
|
58
|
+
/** `apply_cap`: anyone applies the proposed managing cap once its notice has passed. */
|
|
59
|
+
applyCap(options: {
|
|
60
|
+
partner: SharedObjectReference<true>;
|
|
61
|
+
}): (tx: Transaction) => void;
|
|
62
|
+
/** `cancel_share` (`PartnerAdmin`): discards the proposed share, even a ready one. */
|
|
63
|
+
cancelShare(options: {
|
|
64
|
+
partner: SharedObjectReference<true>;
|
|
65
|
+
adminWitness: TransactionObjectInput;
|
|
66
|
+
}): (tx: Transaction) => void;
|
|
67
|
+
/** `cancel_cap` (`PartnerAdmin`): discards the proposed managing cap, even a ready one. */
|
|
68
|
+
cancelCap(options: {
|
|
69
|
+
partner: SharedObjectReference<true>;
|
|
70
|
+
adminWitness: TransactionObjectInput;
|
|
71
|
+
}): (tx: Transaction) => void;
|
|
72
|
+
/** `set_recipient`: the partner's applied cap sets where it is paid, at once. */
|
|
73
|
+
setRecipient(options: {
|
|
74
|
+
partner: SharedObjectReference<true>;
|
|
75
|
+
partnerCap: TransactionObjectInput;
|
|
76
|
+
recipient: string;
|
|
77
|
+
}): (tx: Transaction) => void;
|
|
78
|
+
destroyCap(options: {
|
|
79
|
+
partnerCap: TransactionObjectInput;
|
|
80
|
+
}): (tx: Transaction) => void;
|
|
81
|
+
}
|
|
82
|
+
export declare class PartnersTransactions {
|
|
83
|
+
#private;
|
|
84
|
+
readonly call: PartnersCalls;
|
|
85
|
+
constructor(deployment: PartnersDeployment);
|
|
86
|
+
/** Mints a `PartnerCap` and sends it to `recipient`. */
|
|
87
|
+
newCap(options: {
|
|
88
|
+
recipient: string;
|
|
89
|
+
}): Transaction;
|
|
90
|
+
register(options: {
|
|
91
|
+
adminCapId: string;
|
|
92
|
+
capId: string;
|
|
93
|
+
recipient: string;
|
|
94
|
+
shareBps: bigint;
|
|
95
|
+
}): Transaction;
|
|
96
|
+
scheduleShare(options: {
|
|
97
|
+
adminCapId: string;
|
|
98
|
+
partner: SharedObjectReference<true>;
|
|
99
|
+
shareBps: bigint;
|
|
100
|
+
}): Transaction;
|
|
101
|
+
scheduleCap(options: {
|
|
102
|
+
adminCapId: string;
|
|
103
|
+
partner: SharedObjectReference<true>;
|
|
104
|
+
capId: string;
|
|
105
|
+
}): Transaction;
|
|
106
|
+
applyShare(options: {
|
|
107
|
+
partner: SharedObjectReference<true>;
|
|
108
|
+
}): Transaction;
|
|
109
|
+
applyCap(options: {
|
|
110
|
+
partner: SharedObjectReference<true>;
|
|
111
|
+
}): Transaction;
|
|
112
|
+
cancelShare(options: {
|
|
113
|
+
adminCapId: string;
|
|
114
|
+
partner: SharedObjectReference<true>;
|
|
115
|
+
}): Transaction;
|
|
116
|
+
cancelCap(options: {
|
|
117
|
+
adminCapId: string;
|
|
118
|
+
partner: SharedObjectReference<true>;
|
|
119
|
+
}): Transaction;
|
|
120
|
+
setRecipient(options: {
|
|
121
|
+
partner: SharedObjectReference<true>;
|
|
122
|
+
partnerCapId: string;
|
|
123
|
+
recipient: string;
|
|
124
|
+
}): Transaction;
|
|
125
|
+
destroyCap(options: {
|
|
126
|
+
partnerCapId: string;
|
|
127
|
+
}): Transaction;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EACL,UAAU,EAEX,MAAM,iDAAiD,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EACV,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE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CAAC,CAAC;QACrC,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,WAAW,CAId;IAED,WAAW,CAAC,OAAO,EAAE;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACrC,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,WAAW,CAId;IAED,UAAU,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,WAAW,CAIzE;IAED,QAAQ,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,WAAW,CAIvE;IAED,WAAW,CAAC,OAAO,EAAE;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;KACtC,GAAG,WAAW,CAId;IAED,SAAS,CAAC,OAAO,EAAE;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;KACtC,GAAG,WAAW,CAId;IAED,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACrC,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,WAAW,CAMd;IAED,UAAU,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,WAAW,CAIzD;CAaF"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { AdminCalls, normalizeAdminDeployment, } from "@interest-protocol/blast-admin-sdk/transactions";
|
|
2
|
+
import { requireBasisPoints } from "@interest-protocol/blast-core/integers";
|
|
3
|
+
import { normalizeSharedObjectReference } from "@interest-protocol/blast-core/sui";
|
|
4
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
5
|
+
import { normalizeSuiAddress, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
6
|
+
/** `blast_partners::blast_partners` calls. */
|
|
7
|
+
export class PartnersCalls {
|
|
8
|
+
deployment;
|
|
9
|
+
admin;
|
|
10
|
+
constructor(deployment) {
|
|
11
|
+
this.deployment = {
|
|
12
|
+
packageId: normalizeSuiObjectId(deployment.packageId),
|
|
13
|
+
admin: normalizeAdminDeployment(deployment.admin),
|
|
14
|
+
};
|
|
15
|
+
this.admin = new AdminCalls(this.deployment.admin);
|
|
16
|
+
}
|
|
17
|
+
/** The `PartnerAdmin` role type, for `AdminCalls.grantRole`. */
|
|
18
|
+
roleType() {
|
|
19
|
+
return `${this.deployment.packageId}::blast_partners::PartnerAdmin`;
|
|
20
|
+
}
|
|
21
|
+
/** This PTB's `AdminWitness<PartnerAdmin>`. */
|
|
22
|
+
signIn(options) {
|
|
23
|
+
return this.admin.signIn({
|
|
24
|
+
adminCap: options.adminCap,
|
|
25
|
+
role: this.roleType(),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** `new_cap`: anyone may mint one; it controls nothing until a partner names it. */
|
|
29
|
+
newCap() {
|
|
30
|
+
return (tx) => tx.moveCall({ target: this.#target("new_cap") });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `register` (`PartnerAdmin`): shares a partner managed by the cap
|
|
34
|
+
* `capId`, its share and cap in force at once.
|
|
35
|
+
*/
|
|
36
|
+
register(options) {
|
|
37
|
+
const capId = normalizeSuiObjectId(options.capId);
|
|
38
|
+
const recipient = normalizeSuiAddress(options.recipient);
|
|
39
|
+
const shareBps = requireBasisPoints("shareBps", options.shareBps);
|
|
40
|
+
return (tx) => {
|
|
41
|
+
tx.moveCall({
|
|
42
|
+
target: this.#target("register"),
|
|
43
|
+
arguments: [
|
|
44
|
+
tx.object(options.adminWitness),
|
|
45
|
+
tx.pure.id(capId),
|
|
46
|
+
tx.pure.address(recipient),
|
|
47
|
+
tx.pure.u64(shareBps),
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `schedule_share` (`PartnerAdmin`): proposes the share, which `applyShare`
|
|
54
|
+
* applies once `PARTNER_DELAY_MS` has passed. A new proposal replaces a
|
|
55
|
+
* pending one and restarts the notice.
|
|
56
|
+
*/
|
|
57
|
+
scheduleShare(options) {
|
|
58
|
+
const shareBps = requireBasisPoints("shareBps", options.shareBps);
|
|
59
|
+
return (tx) => {
|
|
60
|
+
tx.moveCall({
|
|
61
|
+
target: this.#target("schedule_share"),
|
|
62
|
+
arguments: [
|
|
63
|
+
partner(tx, options.partner),
|
|
64
|
+
tx.object(options.adminWitness),
|
|
65
|
+
tx.pure.u64(shareBps),
|
|
66
|
+
tx.object.clock(),
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `schedule_cap` (`PartnerAdmin`): proposes moving the partner to the cap
|
|
73
|
+
* `capId`, which `applyCap` applies once `PARTNER_DELAY_MS` has passed.
|
|
74
|
+
*/
|
|
75
|
+
scheduleCap(options) {
|
|
76
|
+
const capId = normalizeSuiObjectId(options.capId);
|
|
77
|
+
return (tx) => {
|
|
78
|
+
tx.moveCall({
|
|
79
|
+
target: this.#target("schedule_cap"),
|
|
80
|
+
arguments: [
|
|
81
|
+
partner(tx, options.partner),
|
|
82
|
+
tx.object(options.adminWitness),
|
|
83
|
+
tx.pure.id(capId),
|
|
84
|
+
tx.object.clock(),
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** `apply_share`: anyone applies the proposed share once its notice has passed. */
|
|
90
|
+
applyShare(options) {
|
|
91
|
+
return (tx) => {
|
|
92
|
+
tx.moveCall({
|
|
93
|
+
target: this.#target("apply_share"),
|
|
94
|
+
arguments: [partner(tx, options.partner), tx.object.clock()],
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** `apply_cap`: anyone applies the proposed managing cap once its notice has passed. */
|
|
99
|
+
applyCap(options) {
|
|
100
|
+
return (tx) => {
|
|
101
|
+
tx.moveCall({
|
|
102
|
+
target: this.#target("apply_cap"),
|
|
103
|
+
arguments: [partner(tx, options.partner), tx.object.clock()],
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** `cancel_share` (`PartnerAdmin`): discards the proposed share, even a ready one. */
|
|
108
|
+
cancelShare(options) {
|
|
109
|
+
return (tx) => {
|
|
110
|
+
tx.moveCall({
|
|
111
|
+
target: this.#target("cancel_share"),
|
|
112
|
+
arguments: [
|
|
113
|
+
partner(tx, options.partner),
|
|
114
|
+
tx.object(options.adminWitness),
|
|
115
|
+
],
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** `cancel_cap` (`PartnerAdmin`): discards the proposed managing cap, even a ready one. */
|
|
120
|
+
cancelCap(options) {
|
|
121
|
+
return (tx) => {
|
|
122
|
+
tx.moveCall({
|
|
123
|
+
target: this.#target("cancel_cap"),
|
|
124
|
+
arguments: [
|
|
125
|
+
partner(tx, options.partner),
|
|
126
|
+
tx.object(options.adminWitness),
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** `set_recipient`: the partner's applied cap sets where it is paid, at once. */
|
|
132
|
+
setRecipient(options) {
|
|
133
|
+
const recipient = normalizeSuiAddress(options.recipient);
|
|
134
|
+
return (tx) => {
|
|
135
|
+
tx.moveCall({
|
|
136
|
+
target: this.#target("set_recipient"),
|
|
137
|
+
arguments: [
|
|
138
|
+
partner(tx, options.partner),
|
|
139
|
+
tx.object(options.partnerCap),
|
|
140
|
+
tx.pure.address(recipient),
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
destroyCap(options) {
|
|
146
|
+
return (tx) => {
|
|
147
|
+
tx.moveCall({
|
|
148
|
+
target: this.#target("destroy_cap"),
|
|
149
|
+
arguments: [tx.object(options.partnerCap)],
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
#target(functionName) {
|
|
154
|
+
return `${this.deployment.packageId}::blast_partners::${functionName}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export class PartnersTransactions {
|
|
158
|
+
call;
|
|
159
|
+
constructor(deployment) {
|
|
160
|
+
this.call = new PartnersCalls(deployment);
|
|
161
|
+
}
|
|
162
|
+
/** Mints a `PartnerCap` and sends it to `recipient`. */
|
|
163
|
+
newCap(options) {
|
|
164
|
+
const tx = new Transaction();
|
|
165
|
+
const cap = tx.add(this.call.newCap());
|
|
166
|
+
tx.transferObjects([cap], normalizeSuiAddress(options.recipient));
|
|
167
|
+
return tx;
|
|
168
|
+
}
|
|
169
|
+
register(options) {
|
|
170
|
+
return this.#asPartnerAdmin(options.adminCapId, (adminWitness) => this.call.register({ ...options, adminWitness }));
|
|
171
|
+
}
|
|
172
|
+
scheduleShare(options) {
|
|
173
|
+
return this.#asPartnerAdmin(options.adminCapId, (adminWitness) => this.call.scheduleShare({ ...options, adminWitness }));
|
|
174
|
+
}
|
|
175
|
+
scheduleCap(options) {
|
|
176
|
+
return this.#asPartnerAdmin(options.adminCapId, (adminWitness) => this.call.scheduleCap({ ...options, adminWitness }));
|
|
177
|
+
}
|
|
178
|
+
applyShare(options) {
|
|
179
|
+
const tx = new Transaction();
|
|
180
|
+
tx.add(this.call.applyShare(options));
|
|
181
|
+
return tx;
|
|
182
|
+
}
|
|
183
|
+
applyCap(options) {
|
|
184
|
+
const tx = new Transaction();
|
|
185
|
+
tx.add(this.call.applyCap(options));
|
|
186
|
+
return tx;
|
|
187
|
+
}
|
|
188
|
+
cancelShare(options) {
|
|
189
|
+
return this.#asPartnerAdmin(options.adminCapId, (adminWitness) => this.call.cancelShare({ ...options, adminWitness }));
|
|
190
|
+
}
|
|
191
|
+
cancelCap(options) {
|
|
192
|
+
return this.#asPartnerAdmin(options.adminCapId, (adminWitness) => this.call.cancelCap({ ...options, adminWitness }));
|
|
193
|
+
}
|
|
194
|
+
setRecipient(options) {
|
|
195
|
+
const tx = new Transaction();
|
|
196
|
+
tx.add(this.call.setRecipient({ ...options, partnerCap: options.partnerCapId }));
|
|
197
|
+
return tx;
|
|
198
|
+
}
|
|
199
|
+
destroyCap(options) {
|
|
200
|
+
const tx = new Transaction();
|
|
201
|
+
tx.add(this.call.destroyCap({ partnerCap: options.partnerCapId }));
|
|
202
|
+
return tx;
|
|
203
|
+
}
|
|
204
|
+
#asPartnerAdmin(adminCapId, call) {
|
|
205
|
+
const tx = new Transaction();
|
|
206
|
+
const adminWitness = tx.add(this.call.signIn({ adminCap: adminCapId }));
|
|
207
|
+
tx.add(call(adminWitness));
|
|
208
|
+
return tx;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function partner(tx, reference) {
|
|
212
|
+
return tx.sharedObjectRef(normalizeSharedObjectReference("partner", reference, true));
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAMnF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAQ9E,8CAA8C;AAC9C,MAAM,OAAO,aAAa;IACf,UAAU,CAAqB;IAC/B,KAAK,CAAa;IAE3B,YAAY,UAA8B;QACxC,IAAI,CAAC,UAAU,GAAG;YAChB,SAAS,EAAE,oBAAoB,CAAC,UAAU,CAAC,S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SAAsC;IAEtC,OAAO,EAAE,CAAC,eAAe,CACvB,8BAA8B,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAC3D,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interest-protocol/blast-partners-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Blast partners SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/interest-protocol/blast-v2-sdk.git",
|
|
9
|
+
"directory": "packages/partners"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
"./events": {
|
|
18
|
+
"types": "./dist/events.d.ts",
|
|
19
|
+
"default": "./dist/events.js"
|
|
20
|
+
},
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./reducer": {
|
|
26
|
+
"types": "./dist/reducer.d.ts",
|
|
27
|
+
"default": "./dist/reducer.js"
|
|
28
|
+
},
|
|
29
|
+
"./state": {
|
|
30
|
+
"types": "./dist/state.d.ts",
|
|
31
|
+
"default": "./dist/state.js"
|
|
32
|
+
},
|
|
33
|
+
"./transactions": {
|
|
34
|
+
"types": "./dist/transactions.d.ts",
|
|
35
|
+
"default": "./dist/transactions.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=22"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "node --eval \"fs.rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"check:package": "publint --strict && attw --pack . --profile esm-only",
|
|
46
|
+
"prepack": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@interest-protocol/blast-admin-sdk": "0.2.0",
|
|
53
|
+
"@interest-protocol/blast-core": "0.2.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@mysten/sui": "^2.26.2"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DecodedDelayedEvent,
|
|
3
|
+
DelayedKeySpecs,
|
|
4
|
+
} from "@interest-protocol/blast-admin-sdk/events";
|
|
5
|
+
import { decodeDelayedEvent } from "@interest-protocol/blast-admin-sdk/events";
|
|
6
|
+
import {
|
|
7
|
+
addressBcs,
|
|
8
|
+
suiObjectIdBcs,
|
|
9
|
+
u64Bcs,
|
|
10
|
+
unitKeyBcs,
|
|
11
|
+
} from "@interest-protocol/blast-core/bcs";
|
|
12
|
+
import type { SuiEventPosition } from "@interest-protocol/blast-core/events";
|
|
13
|
+
import {
|
|
14
|
+
normalizeSuiEventPosition,
|
|
15
|
+
suiEventId,
|
|
16
|
+
} from "@interest-protocol/blast-core/events";
|
|
17
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
18
|
+
import type { SuiClientTypes } from "@mysten/sui/client";
|
|
19
|
+
import {
|
|
20
|
+
normalizeStructTag,
|
|
21
|
+
normalizeSuiAddress,
|
|
22
|
+
parseStructTag,
|
|
23
|
+
} from "@mysten/sui/utils";
|
|
24
|
+
|
|
25
|
+
/** The `blast_partners` events, in Move field order. */
|
|
26
|
+
export const partnerEventBcs = {
|
|
27
|
+
/**
|
|
28
|
+
* At registration and on every recipient change: the partner's recipient.
|
|
29
|
+
* Share and cap terms are `blast_admin::delayed` events (`partnerDelayedKeys`).
|
|
30
|
+
*/
|
|
31
|
+
PartnerUpdated: bcs.struct("PartnerUpdated", {
|
|
32
|
+
partner_id: suiObjectIdBcs,
|
|
33
|
+
recipient: addressBcs,
|
|
34
|
+
}),
|
|
35
|
+
/** `amount` of the event's coin type sent to the partner's recipient. */
|
|
36
|
+
PartnerPaid: bcs.struct("PartnerPaid", {
|
|
37
|
+
partner_id: suiObjectIdBcs,
|
|
38
|
+
amount: u64Bcs,
|
|
39
|
+
}),
|
|
40
|
+
/**
|
|
41
|
+
* `partner_list::add`: the list owned by `parent` (a product configuration's
|
|
42
|
+
* ID) accepts `partner_id` without end.
|
|
43
|
+
*/
|
|
44
|
+
PartnerAdded: bcs.struct("PartnerAdded", {
|
|
45
|
+
parent: suiObjectIdBcs,
|
|
46
|
+
partner_id: suiObjectIdBcs,
|
|
47
|
+
}),
|
|
48
|
+
/** `partner_list::remove`: new sales stop naming the partner from `acceptance_ends_at_ms`. */
|
|
49
|
+
PartnerRemoved: bcs.struct("PartnerRemoved", {
|
|
50
|
+
parent: suiObjectIdBcs,
|
|
51
|
+
partner_id: suiObjectIdBcs,
|
|
52
|
+
acceptance_ends_at_ms: u64Bcs,
|
|
53
|
+
}),
|
|
54
|
+
/** `partner_list::destroy`: the list owned by `parent` and its entries are gone. */
|
|
55
|
+
PartnerListDestroyed: bcs.struct("PartnerListDestroyed", {
|
|
56
|
+
parent: suiObjectIdBcs,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type PartnerEventKind = keyof typeof partnerEventBcs;
|
|
61
|
+
|
|
62
|
+
/** The module each event is defined in. */
|
|
63
|
+
const PARTNER_EVENT_MODULES: Record<PartnerEventKind, string> = {
|
|
64
|
+
PartnerUpdated: "blast_partners",
|
|
65
|
+
PartnerPaid: "blast_partners",
|
|
66
|
+
PartnerAdded: "partner_list",
|
|
67
|
+
PartnerRemoved: "partner_list",
|
|
68
|
+
PartnerListDestroyed: "partner_list",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type PartnerEventPayloads = {
|
|
72
|
+
[Kind in PartnerEventKind]: ReturnType<
|
|
73
|
+
(typeof partnerEventBcs)[Kind]["parse"]
|
|
74
|
+
>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type DecodedPartnerEvent = {
|
|
78
|
+
[Kind in PartnerEventKind]: {
|
|
79
|
+
source: "partners";
|
|
80
|
+
kind: Kind;
|
|
81
|
+
payload: PartnerEventPayloads[Kind];
|
|
82
|
+
/** `PartnerPaid` only: the paid coin type `T`. */
|
|
83
|
+
coinType: Kind extends "PartnerPaid" ? string : null;
|
|
84
|
+
sender: string;
|
|
85
|
+
position: SuiEventPosition;
|
|
86
|
+
};
|
|
87
|
+
}[PartnerEventKind];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Decodes one `<partnersPackageId>::blast_partners::<Kind>` or
|
|
91
|
+
* `<partnersPackageId>::partner_list::<Kind>` event.
|
|
92
|
+
*/
|
|
93
|
+
export function decodePartnerEvent(
|
|
94
|
+
event: SuiClientTypes.EventEntry,
|
|
95
|
+
partnersPackageId: string,
|
|
96
|
+
): DecodedPartnerEvent {
|
|
97
|
+
const tag = parseStructTag(event.eventType);
|
|
98
|
+
const kind = tag.name as PartnerEventKind;
|
|
99
|
+
const [coinType = null, ...extra] = tag.typeParams;
|
|
100
|
+
if (
|
|
101
|
+
tag.address !== normalizeSuiAddress(partnersPackageId) ||
|
|
102
|
+
!Object.hasOwn(partnerEventBcs, kind) ||
|
|
103
|
+
tag.module !== PARTNER_EVENT_MODULES[kind] ||
|
|
104
|
+
(coinType === null) === (kind === "PartnerPaid") ||
|
|
105
|
+
extra.length > 0
|
|
106
|
+
) {
|
|
107
|
+
throw new TypeError(`unexpected partner event type ${event.eventType}`);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
source: "partners",
|
|
111
|
+
kind,
|
|
112
|
+
payload: partnerEventBcs[kind].parse(event.bcs),
|
|
113
|
+
coinType: coinType && normalizeStructTag(coinType),
|
|
114
|
+
sender: normalizeSuiAddress(event.sender),
|
|
115
|
+
position: normalizeSuiEventPosition(event),
|
|
116
|
+
} as DecodedPartnerEvent;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function partnerEventId(event: { position: SuiEventPosition }): string {
|
|
120
|
+
return suiEventId(event.position);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* `blast_partners` keys of `blast_admin::delayed` settings, each owned by the
|
|
125
|
+
* partner: its share in basis points and its managing cap's ID. Registration
|
|
126
|
+
* emits `DelayedCreated` for both; a proposal changes nothing until
|
|
127
|
+
* `DelayedApplied`.
|
|
128
|
+
*/
|
|
129
|
+
export const partnerDelayedKeys = {
|
|
130
|
+
Share: {
|
|
131
|
+
key: "blast_partners::ShareKey",
|
|
132
|
+
family: "setting",
|
|
133
|
+
keyBcs: unitKeyBcs,
|
|
134
|
+
valueBcs: u64Bcs,
|
|
135
|
+
valueType: "u64",
|
|
136
|
+
},
|
|
137
|
+
Cap: {
|
|
138
|
+
key: "blast_partners::CapKey",
|
|
139
|
+
family: "setting",
|
|
140
|
+
keyBcs: unitKeyBcs,
|
|
141
|
+
valueBcs: suiObjectIdBcs,
|
|
142
|
+
valueType: "0x2::object::ID",
|
|
143
|
+
},
|
|
144
|
+
} as const satisfies DelayedKeySpecs;
|
|
145
|
+
|
|
146
|
+
export type DecodedPartnerDelayedEvent = DecodedDelayedEvent<
|
|
147
|
+
typeof partnerDelayedKeys
|
|
148
|
+
>;
|
|
149
|
+
|
|
150
|
+
/** Decodes a `<adminPackageId>::delayed` event keyed by `blast_partners`. */
|
|
151
|
+
export function decodePartnerDelayedEvent(
|
|
152
|
+
event: SuiClientTypes.EventEntry,
|
|
153
|
+
packages: { adminPackageId: string; partnersPackageId: string },
|
|
154
|
+
): DecodedPartnerDelayedEvent {
|
|
155
|
+
return decodeDelayedEvent(event, {
|
|
156
|
+
adminPackageId: packages.adminPackageId,
|
|
157
|
+
packageId: packages.partnersPackageId,
|
|
158
|
+
keys: partnerDelayedKeys,
|
|
159
|
+
});
|
|
160
|
+
}
|
package/src/index.ts
ADDED