@awarizon/core 2.0.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 +264 -0
- package/dist/index.d.mts +420 -0
- package/dist/index.d.ts +420 -0
- package/dist/index.js +816 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +837 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import { KeyringPair } from '@polkadot/keyring/types';
|
|
3
|
+
import { AppCategory, IdentityRecord, NameLookup, ChainType, LinkedAddress } from '@awarizon/sdk';
|
|
4
|
+
export { ChainType, DEFAULT_ENDPOINT, IdentityRecord, LinkStatus, LinkedAddress, MAX_CAMPAIGN_DURATION_DAYS, MICRO_RIZ, MIN_CAMPAIGN_DURATION_DAYS, MIN_INTERACTIONS, MIN_SESSION_SECONDS, NameLookup, PLANCK, RIZ } from '@awarizon/sdk';
|
|
5
|
+
|
|
6
|
+
interface TxResult {
|
|
7
|
+
hash: string;
|
|
8
|
+
blockNumber: number;
|
|
9
|
+
success: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface Balance {
|
|
12
|
+
free: string;
|
|
13
|
+
staked: string;
|
|
14
|
+
reserved: string;
|
|
15
|
+
total: string;
|
|
16
|
+
freePlanck: bigint;
|
|
17
|
+
}
|
|
18
|
+
interface GeneratedWallet {
|
|
19
|
+
mnemonic: string;
|
|
20
|
+
address: string;
|
|
21
|
+
publicKey: string;
|
|
22
|
+
}
|
|
23
|
+
interface WalletAccount {
|
|
24
|
+
address: string;
|
|
25
|
+
publicKey: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
interface InboxItem {
|
|
29
|
+
recordId: string;
|
|
30
|
+
campaignId: string;
|
|
31
|
+
developer: string;
|
|
32
|
+
manifestHash: string;
|
|
33
|
+
category: string;
|
|
34
|
+
status: 'Pending' | 'Delivered' | 'Dismissed' | 'Engaged';
|
|
35
|
+
deliveredAt: number;
|
|
36
|
+
engagedAt: number | null;
|
|
37
|
+
rewardClaimed: boolean;
|
|
38
|
+
rewardEligible: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface ClaimResult extends TxResult {
|
|
41
|
+
reward: string;
|
|
42
|
+
}
|
|
43
|
+
interface DeveloperStatus {
|
|
44
|
+
registered: boolean;
|
|
45
|
+
verified: boolean;
|
|
46
|
+
stake: string;
|
|
47
|
+
totalCampaigns: number;
|
|
48
|
+
totalDeliveries: number;
|
|
49
|
+
violationCount: number;
|
|
50
|
+
}
|
|
51
|
+
interface AppManifest {
|
|
52
|
+
manifestHash: string;
|
|
53
|
+
developer: string;
|
|
54
|
+
category: string;
|
|
55
|
+
registeredAt: number;
|
|
56
|
+
metadataUri: string;
|
|
57
|
+
}
|
|
58
|
+
interface Campaign {
|
|
59
|
+
campaignId: string;
|
|
60
|
+
developer: string;
|
|
61
|
+
manifestHash: string;
|
|
62
|
+
status: 'Pending' | 'Active' | 'Expired' | 'Terminated';
|
|
63
|
+
createdAt: number;
|
|
64
|
+
expiresAt: number;
|
|
65
|
+
maxDeliveries: number;
|
|
66
|
+
currentDeliveries: number;
|
|
67
|
+
targetingDescription: string;
|
|
68
|
+
}
|
|
69
|
+
interface Asset {
|
|
70
|
+
id: number;
|
|
71
|
+
name: string;
|
|
72
|
+
symbol: string;
|
|
73
|
+
decimals: number;
|
|
74
|
+
supply: string;
|
|
75
|
+
owner: string;
|
|
76
|
+
}
|
|
77
|
+
interface AssetBalance {
|
|
78
|
+
assetId: number;
|
|
79
|
+
symbol: string;
|
|
80
|
+
balance: string;
|
|
81
|
+
balanceRaw: bigint;
|
|
82
|
+
}
|
|
83
|
+
interface NFTItem {
|
|
84
|
+
collection: number;
|
|
85
|
+
item: number;
|
|
86
|
+
owner: string;
|
|
87
|
+
metadata: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
interface ValidatorInfo {
|
|
90
|
+
address: string;
|
|
91
|
+
selfStake: string;
|
|
92
|
+
delegatedStake: string;
|
|
93
|
+
totalStake: string;
|
|
94
|
+
performanceScore: number;
|
|
95
|
+
uptime: number;
|
|
96
|
+
slashCount: number;
|
|
97
|
+
isActive: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface NetworkStats {
|
|
100
|
+
totalWallets: number;
|
|
101
|
+
totalDeliveries: number;
|
|
102
|
+
activeCampaigns: number;
|
|
103
|
+
totalStaked: string;
|
|
104
|
+
currentEpoch: number;
|
|
105
|
+
inboxReserve: string;
|
|
106
|
+
totalExtrinsics: number;
|
|
107
|
+
circulatingSupply: string;
|
|
108
|
+
nonCirculatingSupply: string;
|
|
109
|
+
}
|
|
110
|
+
interface TargetingOptions {
|
|
111
|
+
categories?: string[];
|
|
112
|
+
minBalance?: string;
|
|
113
|
+
maxBalance?: string;
|
|
114
|
+
minWalletAge?: number;
|
|
115
|
+
maxWalletAge?: number;
|
|
116
|
+
minActivity?: number;
|
|
117
|
+
maxActivity?: number;
|
|
118
|
+
regions?: number[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare class AwarizonKeyring {
|
|
122
|
+
private keyring;
|
|
123
|
+
constructor();
|
|
124
|
+
initialize(): Promise<void>;
|
|
125
|
+
generate(wordCount?: 12 | 24): GeneratedWallet;
|
|
126
|
+
validate(mnemonic: string): boolean;
|
|
127
|
+
fromMnemonic(mnemonic: string): KeyringPair;
|
|
128
|
+
derive(mnemonic: string, path: string): KeyringPair;
|
|
129
|
+
encrypt(pair: KeyringPair, password: string): string;
|
|
130
|
+
decrypt(encrypted: string, password: string): KeyringPair;
|
|
131
|
+
getAccount(pair: KeyringPair): WalletAccount;
|
|
132
|
+
exportJson(pair: KeyringPair, password: string): string;
|
|
133
|
+
importJson(json: string, password: string): KeyringPair;
|
|
134
|
+
toAddress(publicKey: string): string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare class NetworkModule {
|
|
138
|
+
private api;
|
|
139
|
+
constructor(api: ApiPromise);
|
|
140
|
+
stats(): Promise<NetworkStats>;
|
|
141
|
+
tokenStats(): Promise<{
|
|
142
|
+
totalIssuance: string;
|
|
143
|
+
engagementPool: string;
|
|
144
|
+
}>;
|
|
145
|
+
validatorCount(): Promise<number>;
|
|
146
|
+
activeValidators(): Promise<string[]>;
|
|
147
|
+
subscribeBlocks(callback: (blockNumber: number, hash: string) => void): Promise<() => void>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare class WalletModule {
|
|
151
|
+
private api;
|
|
152
|
+
constructor(api: ApiPromise);
|
|
153
|
+
balance(address: string): Promise<Balance>;
|
|
154
|
+
send(params: {
|
|
155
|
+
to: string;
|
|
156
|
+
amount: string;
|
|
157
|
+
signer: KeyringPair;
|
|
158
|
+
}): Promise<TxResult>;
|
|
159
|
+
totalIssuance(): Promise<string>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare class InboxModule {
|
|
163
|
+
private api;
|
|
164
|
+
constructor(api: ApiPromise);
|
|
165
|
+
list(address: string): Promise<InboxItem[]>;
|
|
166
|
+
get(address: string, recordId: string): Promise<InboxItem | null>;
|
|
167
|
+
count(address: string): Promise<number>;
|
|
168
|
+
engage(params: {
|
|
169
|
+
recordId: string;
|
|
170
|
+
sessionSeconds?: number;
|
|
171
|
+
interactions?: number;
|
|
172
|
+
signer: KeyringPair;
|
|
173
|
+
}): Promise<TxResult>;
|
|
174
|
+
claim(params: {
|
|
175
|
+
recordId: string;
|
|
176
|
+
signer: KeyringPair;
|
|
177
|
+
}): Promise<ClaimResult>;
|
|
178
|
+
dismiss(params: {
|
|
179
|
+
recordId: string;
|
|
180
|
+
signer: KeyringPair;
|
|
181
|
+
}): Promise<TxResult>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare class DeveloperModule {
|
|
185
|
+
private api;
|
|
186
|
+
constructor(api: ApiPromise);
|
|
187
|
+
register(params: {
|
|
188
|
+
signer: KeyringPair;
|
|
189
|
+
}): Promise<TxResult>;
|
|
190
|
+
stake(params: {
|
|
191
|
+
amount: string;
|
|
192
|
+
signer: KeyringPair;
|
|
193
|
+
}): Promise<TxResult>;
|
|
194
|
+
status(address: string): Promise<DeveloperStatus | null>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
declare class AppsModule {
|
|
198
|
+
private api;
|
|
199
|
+
constructor(api: ApiPromise);
|
|
200
|
+
register(params: {
|
|
201
|
+
manifestHash: string;
|
|
202
|
+
category: AppCategory;
|
|
203
|
+
metadataUri: string;
|
|
204
|
+
signer: KeyringPair;
|
|
205
|
+
}): Promise<TxResult & {
|
|
206
|
+
manifestHash: string;
|
|
207
|
+
}>;
|
|
208
|
+
list(developerAddress: string): Promise<AppManifest[]>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
declare class CampaignsModule {
|
|
212
|
+
private api;
|
|
213
|
+
constructor(api: ApiPromise);
|
|
214
|
+
create(params: {
|
|
215
|
+
manifestHash: string;
|
|
216
|
+
targeting: TargetingOptions;
|
|
217
|
+
durationDays: number;
|
|
218
|
+
maxDeliveries: bigint;
|
|
219
|
+
signer: KeyringPair;
|
|
220
|
+
}): Promise<TxResult & {
|
|
221
|
+
campaignId: string;
|
|
222
|
+
}>;
|
|
223
|
+
get(campaignId: string): Promise<Campaign | null>;
|
|
224
|
+
terminate(params: {
|
|
225
|
+
campaignId: string;
|
|
226
|
+
signer: KeyringPair;
|
|
227
|
+
}): Promise<TxResult>;
|
|
228
|
+
deliver(params: {
|
|
229
|
+
campaignId: string;
|
|
230
|
+
wallet: string;
|
|
231
|
+
recordId: string;
|
|
232
|
+
signer: KeyringPair;
|
|
233
|
+
}): Promise<TxResult>;
|
|
234
|
+
deliveryStatus(campaignId: string): Promise<{
|
|
235
|
+
current: number;
|
|
236
|
+
max: number;
|
|
237
|
+
remaining: number;
|
|
238
|
+
percentage: number;
|
|
239
|
+
} | null>;
|
|
240
|
+
describeTargeting(opts: TargetingOptions): string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
declare class AssetsModule {
|
|
244
|
+
private api;
|
|
245
|
+
constructor(api: ApiPromise);
|
|
246
|
+
create(params: {
|
|
247
|
+
id: number;
|
|
248
|
+
admin: string;
|
|
249
|
+
minBalance: bigint;
|
|
250
|
+
signer: KeyringPair;
|
|
251
|
+
}): Promise<TxResult & {
|
|
252
|
+
assetId: number;
|
|
253
|
+
}>;
|
|
254
|
+
mint(params: {
|
|
255
|
+
assetId: number;
|
|
256
|
+
to: string;
|
|
257
|
+
amount: bigint;
|
|
258
|
+
signer: KeyringPair;
|
|
259
|
+
}): Promise<TxResult>;
|
|
260
|
+
transfer(params: {
|
|
261
|
+
assetId: number;
|
|
262
|
+
to: string;
|
|
263
|
+
amount: bigint;
|
|
264
|
+
signer: KeyringPair;
|
|
265
|
+
}): Promise<TxResult>;
|
|
266
|
+
burn(params: {
|
|
267
|
+
assetId: number;
|
|
268
|
+
who: string;
|
|
269
|
+
amount: bigint;
|
|
270
|
+
signer: KeyringPair;
|
|
271
|
+
}): Promise<TxResult>;
|
|
272
|
+
balance(params: {
|
|
273
|
+
assetId: number;
|
|
274
|
+
address: string;
|
|
275
|
+
}): Promise<AssetBalance>;
|
|
276
|
+
metadata(assetId: number): Promise<{
|
|
277
|
+
name: string;
|
|
278
|
+
symbol: string;
|
|
279
|
+
decimals: number;
|
|
280
|
+
}>;
|
|
281
|
+
info(assetId: number): Promise<Asset | null>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare class NFTsModule {
|
|
285
|
+
private api;
|
|
286
|
+
constructor(api: ApiPromise);
|
|
287
|
+
createCollection(params: {
|
|
288
|
+
collectionId: number;
|
|
289
|
+
admin: string;
|
|
290
|
+
signer: KeyringPair;
|
|
291
|
+
}): Promise<TxResult & {
|
|
292
|
+
collectionId: number;
|
|
293
|
+
}>;
|
|
294
|
+
mint(params: {
|
|
295
|
+
collection: number;
|
|
296
|
+
itemId: number;
|
|
297
|
+
owner: string;
|
|
298
|
+
signer: KeyringPair;
|
|
299
|
+
}): Promise<TxResult>;
|
|
300
|
+
transfer(params: {
|
|
301
|
+
collection: number;
|
|
302
|
+
item: number;
|
|
303
|
+
to: string;
|
|
304
|
+
signer: KeyringPair;
|
|
305
|
+
}): Promise<TxResult>;
|
|
306
|
+
burn(params: {
|
|
307
|
+
collection: number;
|
|
308
|
+
item: number;
|
|
309
|
+
signer: KeyringPair;
|
|
310
|
+
}): Promise<TxResult>;
|
|
311
|
+
ownerOf(params: {
|
|
312
|
+
collection: number;
|
|
313
|
+
item: number;
|
|
314
|
+
}): Promise<string | null>;
|
|
315
|
+
list(address: string): Promise<NFTItem[]>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
declare class ValidatorsModule {
|
|
319
|
+
private api;
|
|
320
|
+
constructor(api: ApiPromise);
|
|
321
|
+
register(params: {
|
|
322
|
+
stake: string;
|
|
323
|
+
regionCode: number;
|
|
324
|
+
countryCode: number;
|
|
325
|
+
signer: KeyringPair;
|
|
326
|
+
}): Promise<TxResult>;
|
|
327
|
+
delegate(params: {
|
|
328
|
+
to: string;
|
|
329
|
+
amount: string;
|
|
330
|
+
signer: KeyringPair;
|
|
331
|
+
}): Promise<TxResult>;
|
|
332
|
+
undelegate(params: {
|
|
333
|
+
from: string;
|
|
334
|
+
signer: KeyringPair;
|
|
335
|
+
}): Promise<TxResult>;
|
|
336
|
+
performance(address: string): Promise<ValidatorInfo | null>;
|
|
337
|
+
list(): Promise<ValidatorInfo[]>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare class IdentityModule {
|
|
341
|
+
private api;
|
|
342
|
+
constructor(api: ApiPromise);
|
|
343
|
+
get(address: string): Promise<IdentityRecord | null>;
|
|
344
|
+
lookup(name: string): Promise<NameLookup | null>;
|
|
345
|
+
isAvailable(name: string): Promise<boolean>;
|
|
346
|
+
register(params: {
|
|
347
|
+
rizName?: string;
|
|
348
|
+
displayName?: string;
|
|
349
|
+
bio?: string;
|
|
350
|
+
avatarUri?: string;
|
|
351
|
+
website?: string;
|
|
352
|
+
signer: KeyringPair;
|
|
353
|
+
}): Promise<TxResult>;
|
|
354
|
+
update(params: {
|
|
355
|
+
displayName?: string;
|
|
356
|
+
bio?: string;
|
|
357
|
+
avatarUri?: string;
|
|
358
|
+
website?: string;
|
|
359
|
+
signer: KeyringPair;
|
|
360
|
+
}): Promise<TxResult>;
|
|
361
|
+
recalculateReputation(params: {
|
|
362
|
+
account: string;
|
|
363
|
+
signer: KeyringPair;
|
|
364
|
+
}): Promise<TxResult>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
declare class LinksModule {
|
|
368
|
+
private api;
|
|
369
|
+
constructor(api: ApiPromise);
|
|
370
|
+
buildEvmLinkMessage(awarizonAddress: string): string;
|
|
371
|
+
buildSolanaLinkMessage(awarizonAddress: string): string;
|
|
372
|
+
linkEvm(params: {
|
|
373
|
+
evmAddress: string;
|
|
374
|
+
signature: string;
|
|
375
|
+
signer: KeyringPair;
|
|
376
|
+
}): Promise<TxResult>;
|
|
377
|
+
linkSolana(params: {
|
|
378
|
+
solanaPubkey: string;
|
|
379
|
+
signature: string;
|
|
380
|
+
signer: KeyringPair;
|
|
381
|
+
}): Promise<TxResult>;
|
|
382
|
+
unlink(params: {
|
|
383
|
+
chain: ChainType;
|
|
384
|
+
signer: KeyringPair;
|
|
385
|
+
}): Promise<TxResult>;
|
|
386
|
+
list(address: string): Promise<LinkedAddress[]>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
interface CoreConfig {
|
|
390
|
+
endpoint: string;
|
|
391
|
+
}
|
|
392
|
+
declare class AwarizonCore {
|
|
393
|
+
private config;
|
|
394
|
+
private client;
|
|
395
|
+
private api;
|
|
396
|
+
readonly keyring: AwarizonKeyring;
|
|
397
|
+
network: NetworkModule;
|
|
398
|
+
wallet: WalletModule;
|
|
399
|
+
inbox: InboxModule;
|
|
400
|
+
developer: DeveloperModule;
|
|
401
|
+
apps: AppsModule;
|
|
402
|
+
campaigns: CampaignsModule;
|
|
403
|
+
assets: AssetsModule;
|
|
404
|
+
nfts: NFTsModule;
|
|
405
|
+
validators: ValidatorsModule;
|
|
406
|
+
identity: IdentityModule;
|
|
407
|
+
links: LinksModule;
|
|
408
|
+
constructor(config: CoreConfig);
|
|
409
|
+
connect(): Promise<this>;
|
|
410
|
+
disconnect(): Promise<void>;
|
|
411
|
+
isConnected(): boolean;
|
|
412
|
+
getApi(): ApiPromise;
|
|
413
|
+
}
|
|
414
|
+
declare function createCore(config: CoreConfig): Promise<AwarizonCore>;
|
|
415
|
+
|
|
416
|
+
declare function parseAmount(input: string): bigint;
|
|
417
|
+
declare function formatAmount(planck: bigint, decimals?: number): string;
|
|
418
|
+
declare function isValidAmount(input: string): boolean;
|
|
419
|
+
|
|
420
|
+
export { type AppManifest, type Asset, type AssetBalance, AwarizonCore, AwarizonKeyring, type Balance, type Campaign, type ClaimResult, type CoreConfig, type DeveloperStatus, type GeneratedWallet, type InboxItem, type NFTItem, type NetworkStats, type TargetingOptions, type TxResult, type ValidatorInfo, type WalletAccount, createCore, formatAmount, isValidAmount, parseAmount };
|