@audius/sdk 0.0.33 → 0.0.34
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/api/Rewards.d.ts +11 -0
- package/dist/index.cjs.js +68 -52
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +68 -52
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +68 -52
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +62 -48
- package/dist/native-libs.js.map +1 -1
- package/dist/services/solana/rewardsAttester.d.ts +1 -0
- package/package.json +3 -3
- package/src/api/Rewards.ts +39 -12
- package/src/services/solana/rewardsAttester.ts +3 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audius/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"audius": {
|
|
5
|
-
"releaseSHA": "
|
|
5
|
+
"releaseSHA": "c38a6a8f425386cc254501ac0b0d01235b44d36f"
|
|
6
6
|
},
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "dist/index.cjs.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@ethersproject/solidity": "5.0.5",
|
|
45
45
|
"@improbable-eng/grpc-web-node-http-transport": "0.15.0",
|
|
46
46
|
"@project-serum/anchor": "0.24.1",
|
|
47
|
-
"@solana/spl-token": "0.1.
|
|
47
|
+
"@solana/spl-token": "0.1.8",
|
|
48
48
|
"@solana/web3.js": "1.37.1",
|
|
49
49
|
"abi-decoder": "2.4.0",
|
|
50
50
|
"ajv": "6.12.2",
|
package/src/api/Rewards.ts
CHANGED
|
@@ -160,6 +160,7 @@ export class Rewards extends Base {
|
|
|
160
160
|
}: SubmitAndEvaluateConfig) {
|
|
161
161
|
let phase
|
|
162
162
|
let nodesToReselect = null
|
|
163
|
+
let aaoErrorCode = null
|
|
163
164
|
try {
|
|
164
165
|
phase = AttestationPhases.SANITY_CHECKS
|
|
165
166
|
|
|
@@ -180,6 +181,7 @@ export class Rewards extends Base {
|
|
|
180
181
|
discoveryNodeAttestations,
|
|
181
182
|
aaoAttestation,
|
|
182
183
|
error: aggregateError,
|
|
184
|
+
aaoErrorCode: errorCode,
|
|
183
185
|
erroringNodes
|
|
184
186
|
} = await this.aggregateAttestations({
|
|
185
187
|
challengeId,
|
|
@@ -196,6 +198,7 @@ export class Rewards extends Base {
|
|
|
196
198
|
})
|
|
197
199
|
if (aggregateError) {
|
|
198
200
|
nodesToReselect = erroringNodes
|
|
201
|
+
aaoErrorCode = errorCode
|
|
199
202
|
throw new Error(aggregateError)
|
|
200
203
|
}
|
|
201
204
|
|
|
@@ -283,7 +286,13 @@ export class Rewards extends Base {
|
|
|
283
286
|
)
|
|
284
287
|
}
|
|
285
288
|
|
|
286
|
-
return {
|
|
289
|
+
return {
|
|
290
|
+
success: true,
|
|
291
|
+
error: null,
|
|
292
|
+
aaoErrorCode,
|
|
293
|
+
phase: null,
|
|
294
|
+
nodesToReselect: null
|
|
295
|
+
}
|
|
287
296
|
} catch (e) {
|
|
288
297
|
const err = (e as Error).message
|
|
289
298
|
const log =
|
|
@@ -296,7 +305,13 @@ export class Rewards extends Base {
|
|
|
296
305
|
encodedUserId
|
|
297
306
|
)}] challenge-id [${challengeId}] at phase [${phase}] with err: ${err}`
|
|
298
307
|
)
|
|
299
|
-
return {
|
|
308
|
+
return {
|
|
309
|
+
success: false,
|
|
310
|
+
error: err,
|
|
311
|
+
aaoErrorCode,
|
|
312
|
+
phase,
|
|
313
|
+
nodesToReselect
|
|
314
|
+
}
|
|
300
315
|
}
|
|
301
316
|
}
|
|
302
317
|
|
|
@@ -336,6 +351,7 @@ export class Rewards extends Base {
|
|
|
336
351
|
discoveryNodeAttestations: null,
|
|
337
352
|
aaoAttestation: null,
|
|
338
353
|
error: AggregateAttestationError.INSUFFICIENT_DISCOVERY_NODE_COUNT,
|
|
354
|
+
aaoErrorCode: null,
|
|
339
355
|
erroringNodes: null
|
|
340
356
|
}
|
|
341
357
|
}
|
|
@@ -345,21 +361,25 @@ export class Rewards extends Base {
|
|
|
345
361
|
let aaoAttestation: Nullable<AttestationMeta> = null
|
|
346
362
|
|
|
347
363
|
try {
|
|
348
|
-
const {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
364
|
+
const {
|
|
365
|
+
success,
|
|
366
|
+
aaoErrorCode,
|
|
367
|
+
error: aaoAttestationError
|
|
368
|
+
} = await this.getAAOAttestation({
|
|
369
|
+
challengeId,
|
|
370
|
+
specifier,
|
|
371
|
+
handle,
|
|
372
|
+
amount,
|
|
373
|
+
AAOEndpoint,
|
|
374
|
+
oracleEthAddress
|
|
375
|
+
})
|
|
357
376
|
|
|
358
377
|
if (aaoAttestationError) {
|
|
359
378
|
return {
|
|
360
379
|
discoveryNodeAttestations: null,
|
|
361
380
|
aaoAttestation: null,
|
|
362
381
|
error: aaoAttestationError,
|
|
382
|
+
aaoErrorCode,
|
|
363
383
|
erroringNodes: null
|
|
364
384
|
}
|
|
365
385
|
}
|
|
@@ -375,6 +395,7 @@ export class Rewards extends Base {
|
|
|
375
395
|
discoveryNodeAttestations: null,
|
|
376
396
|
aaoAttestation: null,
|
|
377
397
|
error: GetAttestationError.AAO_ATTESTATION_ERROR,
|
|
398
|
+
aaoErrorCode: null,
|
|
378
399
|
erroringNodes: null
|
|
379
400
|
}
|
|
380
401
|
}
|
|
@@ -417,6 +438,7 @@ export class Rewards extends Base {
|
|
|
417
438
|
discoveryNodeAttestations: discoveryNodeSuccesses,
|
|
418
439
|
aaoAttestation,
|
|
419
440
|
error: null,
|
|
441
|
+
aaoErrorCode: null,
|
|
420
442
|
erroringNodes: null
|
|
421
443
|
}
|
|
422
444
|
} catch (e: any) {
|
|
@@ -430,6 +452,7 @@ export class Rewards extends Base {
|
|
|
430
452
|
discoveryNodeAttestations: null,
|
|
431
453
|
aaoAttestation: null,
|
|
432
454
|
error: GetAttestationError.DISCOVERY_NODE_ATTESTATION_ERROR,
|
|
455
|
+
aaoErrorCode: null,
|
|
433
456
|
erroringNodes: null
|
|
434
457
|
}
|
|
435
458
|
}
|
|
@@ -541,13 +564,14 @@ export class Rewards extends Base {
|
|
|
541
564
|
try {
|
|
542
565
|
const response: AxiosResponse<{
|
|
543
566
|
result: string
|
|
567
|
+
errorCode?: number
|
|
544
568
|
needs: keyof typeof GetAttestationError
|
|
545
569
|
}> = await axios(request)
|
|
546
570
|
// if attestation is successful, 'result' represents a signature
|
|
547
571
|
// otherwise, 'result' is false
|
|
548
572
|
// - there may or may not be a value for `needs` if the attestation fails
|
|
549
573
|
// - depending on whether the user can take an action to attempt remediation
|
|
550
|
-
const { result, needs } = response.data
|
|
574
|
+
const { result, errorCode, needs } = response.data
|
|
551
575
|
|
|
552
576
|
if (!result) {
|
|
553
577
|
logger.error(
|
|
@@ -559,6 +583,7 @@ export class Rewards extends Base {
|
|
|
559
583
|
: GetAttestationError.AAO_ATTESTATION_REJECTION
|
|
560
584
|
return {
|
|
561
585
|
success: null,
|
|
586
|
+
aaoErrorCode: errorCode,
|
|
562
587
|
error: mappedErr
|
|
563
588
|
}
|
|
564
589
|
}
|
|
@@ -568,6 +593,7 @@ export class Rewards extends Base {
|
|
|
568
593
|
signature: result,
|
|
569
594
|
ethAddress: oracleEthAddress
|
|
570
595
|
},
|
|
596
|
+
aaoErrorCode: null,
|
|
571
597
|
error: null
|
|
572
598
|
}
|
|
573
599
|
} catch (e) {
|
|
@@ -575,6 +601,7 @@ export class Rewards extends Base {
|
|
|
575
601
|
logger.error(`Failed to get AAO attestation: ${err}`)
|
|
576
602
|
return {
|
|
577
603
|
success: null,
|
|
604
|
+
aaoErrorCode: null,
|
|
578
605
|
error: GetAttestationError.AAO_ATTESTATION_ERROR
|
|
579
606
|
}
|
|
580
607
|
}
|
|
@@ -199,6 +199,7 @@ type Challenge = {
|
|
|
199
199
|
type AttestationResult = Challenge & {
|
|
200
200
|
error?: string
|
|
201
201
|
phase?: string
|
|
202
|
+
aaoErrorCode?: number
|
|
202
203
|
nodesToReselect?: string[] | null
|
|
203
204
|
}
|
|
204
205
|
|
|
@@ -697,7 +698,7 @@ export class RewardsAttester {
|
|
|
697
698
|
)}], challengeId: [${challengeId}], quorum size: [${this.quorumSize}]}`
|
|
698
699
|
)
|
|
699
700
|
|
|
700
|
-
const { success, error, phase, nodesToReselect } =
|
|
701
|
+
const { success, error, aaoErrorCode, phase, nodesToReselect } =
|
|
701
702
|
await this.libs.Rewards.submitAndEvaluate({
|
|
702
703
|
challengeId,
|
|
703
704
|
encodedUserId: userId,
|
|
@@ -750,6 +751,7 @@ export class RewardsAttester {
|
|
|
750
751
|
wallet,
|
|
751
752
|
completedBlocknumber,
|
|
752
753
|
error,
|
|
754
|
+
aaoErrorCode,
|
|
753
755
|
phase,
|
|
754
756
|
nodesToReselect
|
|
755
757
|
}
|