northstar-eva-sdk 0.10.0 → 0.10.1

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.
@@ -1425,8 +1425,16 @@ class NorthstarEva {
1425
1425
  }
1426
1426
  /** eva distributePrize instruction (ER, admin) — pay out the prize pool to `winners` by `amounts` (lamports). */
1427
1427
  async buildDistributePrizeIx(p) {
1428
+ if (p.winners.length !== p.amounts.length)
1429
+ throw new Error(`distributePrize: winners (${p.winners.length}) and amounts (${p.amounts.length}) must be the same length`);
1428
1430
  const g = await this.requireGlobal();
1429
- return this.methods.distributePrize(p.winners, p.amounts.map((a) => this.bn(a))).accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), admin: this.payer }).instruction();
1431
+ // The program pays each winner by finding its account in remaining_accounts (distribute_prize.rs:
1432
+ // `remaining_accounts.find(winner).ok_or(InvalidAmount)`), so EACH winner must be appended as a
1433
+ // writable account — otherwise it fails with InvalidAmount (6005).
1434
+ return this.methods.distributePrize(p.winners, p.amounts.map((a) => this.bn(a)))
1435
+ .accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), admin: this.payer })
1436
+ .remainingAccounts(p.winners.map((w) => ({ pubkey: w, isWritable: true, isSigner: false })))
1437
+ .instruction();
1430
1438
  }
1431
1439
  /**
1432
1440
  * Bundle instruction(s) into an UNSIGNED `Transaction` (feePayer + recent blockhash set) for the
@@ -1356,8 +1356,16 @@ export class NorthstarEva {
1356
1356
  }
1357
1357
  /** eva distributePrize instruction (ER, admin) — pay out the prize pool to `winners` by `amounts` (lamports). */
1358
1358
  async buildDistributePrizeIx(p) {
1359
+ if (p.winners.length !== p.amounts.length)
1360
+ throw new Error(`distributePrize: winners (${p.winners.length}) and amounts (${p.amounts.length}) must be the same length`);
1359
1361
  const g = await this.requireGlobal();
1360
- return this.methods.distributePrize(p.winners, p.amounts.map((a) => this.bn(a))).accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new PublicKey(g.feeRecipient), admin: this.payer }).instruction();
1362
+ // The program pays each winner by finding its account in remaining_accounts (distribute_prize.rs:
1363
+ // `remaining_accounts.find(winner).ok_or(InvalidAmount)`), so EACH winner must be appended as a
1364
+ // writable account — otherwise it fails with InvalidAmount (6005).
1365
+ return this.methods.distributePrize(p.winners, p.amounts.map((a) => this.bn(a)))
1366
+ .accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new PublicKey(g.feeRecipient), admin: this.payer })
1367
+ .remainingAccounts(p.winners.map((w) => ({ pubkey: w, isWritable: true, isSigner: false })))
1368
+ .instruction();
1361
1369
  }
1362
1370
  /**
1363
1371
  * Bundle instruction(s) into an UNSIGNED `Transaction` (feePayer + recent blockhash set) for the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "northstar-eva-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Run the eva program on a NorthStar ephemeral rollup (zero-fee hot path). A high-level class SDK over the NorthStar Portal/ER protocol + the eva Anchor program. Works localnet & devnet.",
5
5
  "type": "module",
6
6
  "license": "MIT",