@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/README.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# @awarizon/core
|
|
2
|
+
|
|
3
|
+
High-level SDK for building on the Awarizon blockchain. 10x faster than working with raw chain primitives.
|
|
4
|
+
|
|
5
|
+
Wraps `@awarizon/sdk` with natural-language amounts, simple async/await, built-in key management, and human-readable errors.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @awarizon/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createCore } from '@awarizon/core'
|
|
17
|
+
|
|
18
|
+
const core = await createCore({ endpoint: 'ws://127.0.0.1:9944' })
|
|
19
|
+
|
|
20
|
+
// Generate a wallet
|
|
21
|
+
const wallet = core.keyring.generate()
|
|
22
|
+
console.log(wallet.address) // SS58 address
|
|
23
|
+
console.log(wallet.mnemonic) // 12-word phrase
|
|
24
|
+
|
|
25
|
+
// Check balance
|
|
26
|
+
const balance = await core.wallet.balance(wallet.address)
|
|
27
|
+
console.log(balance.free) // "0.0000 RIZ"
|
|
28
|
+
|
|
29
|
+
// Send RIZ
|
|
30
|
+
const signer = core.keyring.fromMnemonic(wallet.mnemonic)
|
|
31
|
+
const tx = await core.wallet.send({ to: '5GrwvaEF...', amount: '10 RIZ', signer })
|
|
32
|
+
console.log(tx.hash)
|
|
33
|
+
|
|
34
|
+
await core.disconnect()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Key Management
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { AwarizonKeyring } from '@awarizon/core'
|
|
41
|
+
|
|
42
|
+
const keyring = new AwarizonKeyring()
|
|
43
|
+
await keyring.initialize()
|
|
44
|
+
|
|
45
|
+
// Generate
|
|
46
|
+
const wallet = keyring.generate() // { mnemonic, address, publicKey }
|
|
47
|
+
const wallet24 = keyring.generate(24) // 24-word mnemonic
|
|
48
|
+
|
|
49
|
+
// Import
|
|
50
|
+
const pair = keyring.fromMnemonic('word1 word2 ... word12')
|
|
51
|
+
|
|
52
|
+
// Derive child accounts (multi-account support)
|
|
53
|
+
const account0 = keyring.derive(wallet.mnemonic, '//0')
|
|
54
|
+
const account1 = keyring.derive(wallet.mnemonic, '//1')
|
|
55
|
+
|
|
56
|
+
// Encrypt/decrypt for storage
|
|
57
|
+
const encrypted = keyring.encrypt(pair, 'myPassword') // JSON string
|
|
58
|
+
const decrypted = keyring.decrypt(encrypted, 'myPassword')
|
|
59
|
+
|
|
60
|
+
// Export/import Polkadot-compatible JSON backup
|
|
61
|
+
const json = keyring.exportJson(pair, 'password')
|
|
62
|
+
const restored = keyring.importJson(json, 'password')
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Wallet Operations
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Balance
|
|
69
|
+
const balance = await core.wallet.balance(address)
|
|
70
|
+
// { free: "100.0000 RIZ", staked: "0.0000 RIZ", total: "100.0000 RIZ", freePlanck: 100000000000000n }
|
|
71
|
+
|
|
72
|
+
// Send
|
|
73
|
+
const tx = await core.wallet.send({ to: recipientAddress, amount: '10 RIZ', signer })
|
|
74
|
+
// { hash: "0x...", blockNumber: 0, success: true }
|
|
75
|
+
|
|
76
|
+
// Total issuance
|
|
77
|
+
const supply = await core.wallet.totalIssuance() // "1,000,000.0000 RIZ"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Inbox
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// List inbox items
|
|
84
|
+
const items = await core.inbox.list(address)
|
|
85
|
+
// [{ recordId, campaignId, developer, category, status, rewardEligible, ... }]
|
|
86
|
+
|
|
87
|
+
// Count
|
|
88
|
+
const count = await core.inbox.count(address)
|
|
89
|
+
|
|
90
|
+
// Engage with content
|
|
91
|
+
const tx = await core.inbox.engage({
|
|
92
|
+
recordId: '0xabc...',
|
|
93
|
+
sessionSeconds: 300, // optional, defaults to MIN_SESSION_SECONDS (120)
|
|
94
|
+
interactions: 10, // optional, defaults to MIN_INTERACTIONS (5)
|
|
95
|
+
signer,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// Claim reward
|
|
99
|
+
const reward = await core.inbox.claim({ recordId: '0xabc...', signer })
|
|
100
|
+
console.log(reward.reward) // "1.0000 RIZ"
|
|
101
|
+
|
|
102
|
+
// Dismiss
|
|
103
|
+
await core.inbox.dismiss({ recordId: '0xabc...', signer })
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Developer Tools
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Register as developer
|
|
110
|
+
await core.developer.register({ signer })
|
|
111
|
+
|
|
112
|
+
// Stake RIZ
|
|
113
|
+
await core.developer.stake({ amount: '10000 RIZ', signer })
|
|
114
|
+
|
|
115
|
+
// Check status
|
|
116
|
+
const status = await core.developer.status(address)
|
|
117
|
+
// { registered: true, verified: false, stake: "10000.0000 RIZ", totalCampaigns: 0, ... }
|
|
118
|
+
|
|
119
|
+
// Register app manifest
|
|
120
|
+
const app = await core.apps.register({
|
|
121
|
+
manifestHash: '0xabc123...', // 32-byte hex
|
|
122
|
+
category: 'Gaming',
|
|
123
|
+
metadataUri: 'ipfs://Qm...',
|
|
124
|
+
signer,
|
|
125
|
+
})
|
|
126
|
+
console.log(app.manifestHash)
|
|
127
|
+
|
|
128
|
+
// List developer manifests
|
|
129
|
+
const manifests = await core.apps.list(developerAddress)
|
|
130
|
+
|
|
131
|
+
// Create campaign
|
|
132
|
+
const campaign = await core.campaigns.create({
|
|
133
|
+
manifestHash: '0xabc123...',
|
|
134
|
+
targeting: {
|
|
135
|
+
categories: ['Gaming', 'DeFi'],
|
|
136
|
+
minBalance: '10 RIZ',
|
|
137
|
+
minWalletAge: 30, // days
|
|
138
|
+
},
|
|
139
|
+
durationDays: 30,
|
|
140
|
+
maxDeliveries: 10000n,
|
|
141
|
+
signer,
|
|
142
|
+
})
|
|
143
|
+
console.log(campaign.campaignId)
|
|
144
|
+
|
|
145
|
+
// Get campaign
|
|
146
|
+
const c = await core.campaigns.get(campaignId)
|
|
147
|
+
// { campaignId, status, maxDeliveries, currentDeliveries, ... }
|
|
148
|
+
|
|
149
|
+
// Delivery status
|
|
150
|
+
const ds = await core.campaigns.deliveryStatus(campaignId)
|
|
151
|
+
// { current: 42, max: 10000, remaining: 9958, percentage: 0 }
|
|
152
|
+
|
|
153
|
+
// Terminate
|
|
154
|
+
await core.campaigns.terminate({ campaignId, signer })
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Assets
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Create fungible token (pallet-assets)
|
|
161
|
+
const asset = await core.assets.create({
|
|
162
|
+
id: 1,
|
|
163
|
+
admin: myAddress,
|
|
164
|
+
minBalance: 1n,
|
|
165
|
+
signer,
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Mint tokens
|
|
169
|
+
await core.assets.mint({ assetId: 1, to: recipientAddress, amount: 1000n, signer })
|
|
170
|
+
|
|
171
|
+
// Transfer
|
|
172
|
+
await core.assets.transfer({ assetId: 1, to: recipientAddress, amount: 100n, signer })
|
|
173
|
+
|
|
174
|
+
// Burn
|
|
175
|
+
await core.assets.burn({ assetId: 1, who: myAddress, amount: 50n, signer })
|
|
176
|
+
|
|
177
|
+
// Check balance
|
|
178
|
+
const bal = await core.assets.balance({ assetId: 1, address: myAddress })
|
|
179
|
+
// { assetId: 1, symbol: "1", balance: "950", balanceRaw: 950n }
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## NFTs
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// Create collection (pallet-nfts)
|
|
186
|
+
await core.nfts.createCollection({ collectionId: 1, admin: myAddress, signer })
|
|
187
|
+
|
|
188
|
+
// Mint NFT
|
|
189
|
+
await core.nfts.mint({ collection: 1, itemId: 0, owner: myAddress, signer })
|
|
190
|
+
|
|
191
|
+
// Transfer
|
|
192
|
+
await core.nfts.transfer({ collection: 1, item: 0, to: recipientAddress, signer })
|
|
193
|
+
|
|
194
|
+
// Owner
|
|
195
|
+
const owner = await core.nfts.ownerOf({ collection: 1, item: 0 })
|
|
196
|
+
|
|
197
|
+
// List owned NFTs
|
|
198
|
+
const nfts = await core.nfts.list(myAddress)
|
|
199
|
+
// [{ collection: 1, item: 0, owner: "5G...", metadata: {} }]
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Validators
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// Register as validator
|
|
206
|
+
await core.validators.register({
|
|
207
|
+
stake: '10000 RIZ',
|
|
208
|
+
regionCode: 1,
|
|
209
|
+
countryCode: 44,
|
|
210
|
+
signer,
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
// Delegate stake
|
|
214
|
+
await core.validators.delegate({ to: validatorAddress, amount: '1000 RIZ', signer })
|
|
215
|
+
|
|
216
|
+
// Undelegate
|
|
217
|
+
await core.validators.undelegate({ from: validatorAddress, signer })
|
|
218
|
+
|
|
219
|
+
// Performance info
|
|
220
|
+
const info = await core.validators.performance(validatorAddress)
|
|
221
|
+
// { selfStake, delegatedStake, totalStake, performanceScore, uptime, slashCount, isActive }
|
|
222
|
+
|
|
223
|
+
// List all active validators
|
|
224
|
+
const validators = await core.validators.list()
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Network
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const stats = await core.network.stats()
|
|
231
|
+
// { totalWallets, totalDeliveries, activeCampaigns, totalStaked, currentEpoch, ... }
|
|
232
|
+
|
|
233
|
+
const count = await core.network.validatorCount()
|
|
234
|
+
const active = await core.network.activeValidators() // string[] of SS58 addresses
|
|
235
|
+
|
|
236
|
+
// Subscribe to new blocks
|
|
237
|
+
const unsub = await core.network.subscribeBlocks((blockNumber, hash) => {
|
|
238
|
+
console.log(`Block #${blockNumber}: ${hash}`)
|
|
239
|
+
})
|
|
240
|
+
unsub() // stop subscription
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Amount Format
|
|
244
|
+
|
|
245
|
+
All public API inputs accept human-readable RIZ strings. All outputs return formatted strings.
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { parseAmount, formatAmount, isValidAmount } from '@awarizon/core'
|
|
249
|
+
|
|
250
|
+
// String → planck bigint (internal representation)
|
|
251
|
+
parseAmount('10 RIZ') // 10_000_000_000_000n
|
|
252
|
+
parseAmount('0.5 RIZ') // 500_000_000_000n
|
|
253
|
+
parseAmount('10') // 10_000_000_000_000n (RIZ suffix optional)
|
|
254
|
+
|
|
255
|
+
// planck bigint → display string
|
|
256
|
+
formatAmount(10_000_000_000_000n) // "10.0000 RIZ"
|
|
257
|
+
formatAmount(10_000_000_000_000n, 2) // "10.00 RIZ"
|
|
258
|
+
|
|
259
|
+
// Validate
|
|
260
|
+
isValidAmount('10 RIZ') // true
|
|
261
|
+
isValidAmount('abc') // false
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
RIZ has 12 decimal places (`1 RIZ = 1_000_000_000_000 planck`). Never pass raw planck values to public API methods — always use `"10 RIZ"` strings.
|
package/dist/index.d.mts
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 };
|