Skip to content

Commit

Permalink
fix: use atomicRearrange rather that staging
Browse files Browse the repository at this point in the history
the helper function is compatible with mainnet1B
  • Loading branch information
dckc committed Dec 6, 2023
1 parent e698700 commit fd2b5e7
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions contract/src/gameAssetContract.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/** @file illustrates using non-vbank assets */
/* eslint @typescript-eslint/no-floating-promises: "warn" */
/** @file Contract to mint and sell Place NFTs for a hypothetical game. */
// @ts-check

// deep import to avoid dependency on all of ERTP, vat-data
import { AmountShape } from '@agoric/ertp/src/typeGuards.js';
import { AmountMath, AssetKind } from '@agoric/ertp/src/amountMath.js';
import { M, getCopyBagEntries } from '@endo/patterns';
import { E, Far } from '@endo/far';
import { Far } from '@endo/far';
// Use the deprecated atomicRearrange API
// for compatibility with mainnet1B.
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
import '@agoric/zoe/exported.js';

import { makeTracer } from './debug.js';

Expand Down Expand Up @@ -46,12 +49,15 @@ export const start = async zcf => {

totalPlaces(want.Places) <= 3n || Fail`only 3 places allowed when joining`;

// We use the deprecated stage/reallocate API
// so that we can test this with the version of zoe on mainnet1B.
playerSeat.decrementBy(gameSeat.incrementBy(give));
const tmp = mint.mintGains(want);
playerSeat.incrementBy(tmp.decrementBy(want));
zcf.reallocate(playerSeat, tmp, gameSeat);
atomicRearrange(
zcf,
harden([
[playerSeat, gameSeat, give],
[tmp, playerSeat, want],
]),
);

playerSeat.exit(true);
return 'welcome to the game';
};
Expand Down

0 comments on commit fd2b5e7

Please sign in to comment.