@blockula/sdk 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/dist/index.d.ts +22 -0
- package/dist/index.js +32 -0
- package/dist/tx.d.ts +37 -0
- package/dist/tx.js +38 -0
- package/package.json +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,23 @@ export declare class Wallet {
|
|
|
70
70
|
approveValidator(validator: string): Promise<any>;
|
|
71
71
|
/** Season 0 admins only. */
|
|
72
72
|
removeValidator(validator: string): Promise<any>;
|
|
73
|
+
/** Claim a GitHub handle. Verify it by creating a public gist (as that user) containing this account's address. */
|
|
74
|
+
linkGithub(handle: string, gistId: string): Promise<any>;
|
|
75
|
+
unlinkGithub(handle: string): Promise<any>;
|
|
76
|
+
/** Put a bounty on a GitHub issue. `expiresInBlocks` from now (max ~1 year). */
|
|
77
|
+
createHunt(opts: {
|
|
78
|
+
repo: string;
|
|
79
|
+
issue: number;
|
|
80
|
+
amount: string | number | bigint;
|
|
81
|
+
title: string;
|
|
82
|
+
expiresInBlocks: number;
|
|
83
|
+
}): Promise<any>;
|
|
84
|
+
fundHunt(huntId: number, amount: string | number | bigint): Promise<any>;
|
|
85
|
+
/** Pay a hunt's bounty (creator or admin). `to` may be a .boo name; it's resolved and the address is signed. */
|
|
86
|
+
awardHunt(huntId: number, to: string, pr: number, familiarKey?: string): Promise<any>;
|
|
87
|
+
cancelHunt(huntId: number): Promise<any>;
|
|
88
|
+
/** Mark one of this account's session keys (an agent) as a Familiar. */
|
|
89
|
+
registerFamiliar(keyIdHex: string, label: string): Promise<any>;
|
|
73
90
|
/** Reclaim the bond of a removed validator this account owns. */
|
|
74
91
|
unbond(validator: string): Promise<any>;
|
|
75
92
|
balance(): Promise<string>;
|
|
@@ -103,6 +120,11 @@ export declare class Client {
|
|
|
103
120
|
search(q: string): Promise<any>;
|
|
104
121
|
/** Active set for the current epoch, pending/approved validators, next-epoch set, epoch timing. */
|
|
105
122
|
validators(): Promise<any>;
|
|
123
|
+
/** Hunts (bounties on GitHub issues), biggest first. */
|
|
124
|
+
hunts(status?: "open" | "awarded" | "cancelled" | "expired"): Promise<any>;
|
|
125
|
+
hunt(id: number): Promise<any>;
|
|
126
|
+
/** Off-chain check of a GitHub link (gist owned by the handle containing the address). */
|
|
127
|
+
github(handle: string): Promise<any>;
|
|
106
128
|
resolve(nameOrAddress: string): Promise<string>;
|
|
107
129
|
submit(tx: Tx, wait?: boolean): Promise<any>;
|
|
108
130
|
faucet(to: string, wait?: boolean): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -133,6 +133,33 @@ export class Wallet {
|
|
|
133
133
|
async removeValidator(validator) {
|
|
134
134
|
return this.client.submit(await this.build({ type: "remove_validator", validator }));
|
|
135
135
|
}
|
|
136
|
+
/** Claim a GitHub handle. Verify it by creating a public gist (as that user) containing this account's address. */
|
|
137
|
+
async linkGithub(handle, gistId) {
|
|
138
|
+
return this.client.submit(await this.build({ type: "link_github", handle, gist_id: gistId }));
|
|
139
|
+
}
|
|
140
|
+
async unlinkGithub(handle) {
|
|
141
|
+
return this.client.submit(await this.build({ type: "unlink_github", handle }));
|
|
142
|
+
}
|
|
143
|
+
/** Put a bounty on a GitHub issue. `expiresInBlocks` from now (max ~1 year). */
|
|
144
|
+
async createHunt(opts) {
|
|
145
|
+
const { height } = await this.client.status();
|
|
146
|
+
return this.client.submit(await this.build({ type: "create_hunt", repo: opts.repo, issue: opts.issue, amount: parseFang(opts.amount).toString(), expires_at: height + opts.expiresInBlocks, title: opts.title }));
|
|
147
|
+
}
|
|
148
|
+
async fundHunt(huntId, amount) {
|
|
149
|
+
return this.client.submit(await this.build({ type: "fund_hunt", hunt_id: huntId, amount: parseFang(amount).toString() }));
|
|
150
|
+
}
|
|
151
|
+
/** Pay a hunt's bounty (creator or admin). `to` may be a .boo name; it's resolved and the address is signed. */
|
|
152
|
+
async awardHunt(huntId, to, pr, familiarKey) {
|
|
153
|
+
const addr = await this.client.resolve(to);
|
|
154
|
+
return this.client.submit(await this.build({ type: "award_hunt", hunt_id: huntId, to: addr, pr, ...(familiarKey ? { familiar_key: familiarKey } : {}) }));
|
|
155
|
+
}
|
|
156
|
+
async cancelHunt(huntId) {
|
|
157
|
+
return this.client.submit(await this.build({ type: "cancel_hunt", hunt_id: huntId }));
|
|
158
|
+
}
|
|
159
|
+
/** Mark one of this account's session keys (an agent) as a Familiar. */
|
|
160
|
+
async registerFamiliar(keyIdHex, label) {
|
|
161
|
+
return this.client.submit(await this.build({ type: "register_familiar", key_id: keyIdHex, label }));
|
|
162
|
+
}
|
|
136
163
|
/** Reclaim the bond of a removed validator this account owns. */
|
|
137
164
|
async unbond(validator) {
|
|
138
165
|
return this.client.submit(await this.build({ type: "unbond", validator }));
|
|
@@ -197,6 +224,11 @@ export class Client {
|
|
|
197
224
|
search(q) { return this.call(`/search/${encodeURIComponent(q)}`); }
|
|
198
225
|
/** Active set for the current epoch, pending/approved validators, next-epoch set, epoch timing. */
|
|
199
226
|
validators() { return this.call("/validators"); }
|
|
227
|
+
/** Hunts (bounties on GitHub issues), biggest first. */
|
|
228
|
+
hunts(status) { return this.call(`/hunts${status ? `?status=${status}` : ""}`); }
|
|
229
|
+
hunt(id) { return this.call(`/hunt/${id}`); }
|
|
230
|
+
/** Off-chain check of a GitHub link (gist owned by the handle containing the address). */
|
|
231
|
+
github(handle) { return this.call(`/github/${encodeURIComponent(handle)}`); }
|
|
200
232
|
async resolve(nameOrAddress) {
|
|
201
233
|
if (isAddress(nameOrAddress))
|
|
202
234
|
return nameOrAddress;
|
package/dist/tx.d.ts
CHANGED
|
@@ -46,6 +46,43 @@ export type Action = {
|
|
|
46
46
|
| {
|
|
47
47
|
type: "unbond";
|
|
48
48
|
validator: string;
|
|
49
|
+
}
|
|
50
|
+
/** Claim a GitHub handle; a public gist by that handle containing your boo1 address verifies it. */
|
|
51
|
+
| {
|
|
52
|
+
type: "link_github";
|
|
53
|
+
handle: string;
|
|
54
|
+
gist_id: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: "unlink_github";
|
|
57
|
+
handle: string;
|
|
58
|
+
}
|
|
59
|
+
/** Escrow a bounty on a GitHub issue ("owner/name", issue number). */
|
|
60
|
+
| {
|
|
61
|
+
type: "create_hunt";
|
|
62
|
+
repo: string;
|
|
63
|
+
issue: number;
|
|
64
|
+
amount: string;
|
|
65
|
+
expires_at: number;
|
|
66
|
+
title: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: "fund_hunt";
|
|
69
|
+
hunt_id: number;
|
|
70
|
+
amount: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "award_hunt";
|
|
73
|
+
hunt_id: number;
|
|
74
|
+
to: string;
|
|
75
|
+
pr: number;
|
|
76
|
+
familiar_key?: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: "cancel_hunt";
|
|
79
|
+
hunt_id: number;
|
|
80
|
+
}
|
|
81
|
+
/** Mark one of your session keys as an agent Familiar. */
|
|
82
|
+
| {
|
|
83
|
+
type: "register_familiar";
|
|
84
|
+
key_id: string;
|
|
85
|
+
label: string;
|
|
49
86
|
};
|
|
50
87
|
export interface UnsignedTx {
|
|
51
88
|
chain_id: string;
|
package/dist/tx.js
CHANGED
|
@@ -69,6 +69,44 @@ export function signingBytes(tx) {
|
|
|
69
69
|
w.u8(7);
|
|
70
70
|
w.str(a.validator);
|
|
71
71
|
break;
|
|
72
|
+
case "link_github":
|
|
73
|
+
w.u8(8);
|
|
74
|
+
w.str(a.handle);
|
|
75
|
+
w.str(a.gist_id);
|
|
76
|
+
break;
|
|
77
|
+
case "unlink_github":
|
|
78
|
+
w.u8(9);
|
|
79
|
+
w.str(a.handle);
|
|
80
|
+
break;
|
|
81
|
+
case "create_hunt":
|
|
82
|
+
w.u8(10);
|
|
83
|
+
w.str(a.repo);
|
|
84
|
+
w.u64(BigInt(a.issue));
|
|
85
|
+
w.u64(BigInt(a.amount));
|
|
86
|
+
w.u64(BigInt(a.expires_at));
|
|
87
|
+
w.str(a.title);
|
|
88
|
+
break;
|
|
89
|
+
case "fund_hunt":
|
|
90
|
+
w.u8(11);
|
|
91
|
+
w.u64(BigInt(a.hunt_id));
|
|
92
|
+
w.u64(BigInt(a.amount));
|
|
93
|
+
break;
|
|
94
|
+
case "award_hunt":
|
|
95
|
+
w.u8(12);
|
|
96
|
+
w.u64(BigInt(a.hunt_id));
|
|
97
|
+
w.str(a.to);
|
|
98
|
+
w.u64(BigInt(a.pr));
|
|
99
|
+
w.str(a.familiar_key ?? "");
|
|
100
|
+
break;
|
|
101
|
+
case "cancel_hunt":
|
|
102
|
+
w.u8(13);
|
|
103
|
+
w.u64(BigInt(a.hunt_id));
|
|
104
|
+
break;
|
|
105
|
+
case "register_familiar":
|
|
106
|
+
w.u8(14);
|
|
107
|
+
w.str(a.key_id);
|
|
108
|
+
w.str(a.label);
|
|
109
|
+
break;
|
|
72
110
|
}
|
|
73
111
|
w.str(tx.memo);
|
|
74
112
|
return w.done();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockula/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "\ud83e\udddb TypeScript SDK for Blockula \u2014 post-quantum wallets (ML-DSA-65), .boo names, transfers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -44,5 +44,14 @@
|
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/jackdishman/blockula.git",
|
|
51
|
+
"directory": "sdk-ts"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/jackdishman/blockula#readme",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/jackdishman/blockula/issues"
|
|
47
56
|
}
|
|
48
57
|
}
|