Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from Agoric/nat-4.0.0
Browse files Browse the repository at this point in the history
chore: update to nat 4.0.0
  • Loading branch information
katelynsills authored Feb 23, 2021
2 parents dcc9de2 + ec8595a commit 037e2f7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@agoric/ertp": "*",
"@agoric/eventual-send": "*",
"@agoric/install-ses": "*",
"@agoric/nat": "^2.0.1",
"@agoric/nat": "^4.0.0",
"@agoric/notifier": "*",
"@agoric/store": "*",
"@agoric/swingset-vat": "*",
Expand Down
8 changes: 4 additions & 4 deletions contract/src/pegasus.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { makeNotifierKit } from '@agoric/notifier';
import makeStore from '@agoric/store';
import makeWeakStore from '@agoric/weak-store';
import { E } from '@agoric/eventual-send';
import Nat from '@agoric/nat';
import { Nat } from '@agoric/nat';
import { parse as parseMultiaddr } from '@agoric/swingset-vat/src/vats/network/multiaddr';
import { assertProposalShape } from '@agoric/zoe/src/contractSupport';

import '@agoric/notifier/exports';
import '@agoric/notifier/exported';
import '../exported';

const DEFAULT_AMOUNT_MATH_KIND = 'nat';
Expand Down Expand Up @@ -72,10 +72,10 @@ function makeICS20Converter(localBrand, prefixedDenom) {
*/
function packetToLocalAmount(packet) {
// packet.amount is a string in JSON.
const floatValue = Number(packet.amount);
const bigValue = BigInt(packet.amount);

// If we overflow, or don't have a non-negative integer, throw an exception!
const value = Nat(floatValue);
const value = Nat(bigValue);

return harden({
brand: localBrand,
Expand Down
6 changes: 3 additions & 3 deletions contract/test/test-peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function testRemotePeg(t) {
t.deepEquals(
packet,
{
amount: '100',
amount: '100000000000000000001',
denomination: 'portdef/chanabc/uatom',
receiver: 'markaccount',
},
Expand All @@ -94,7 +94,7 @@ async function testRemotePeg(t) {

// Get some local Atoms.
const sendPacket = {
amount: '100',
amount: '100000000000000000001',
denomination: 'portdef/chanabc/uatom',
receiver: '0x1234',
sender: 'FIXME:sender',
Expand All @@ -110,7 +110,7 @@ async function testRemotePeg(t) {
const localAtomsAmount = await E(localPurseP).getCurrentAmount();
t.deepEquals(
localAtomsAmount,
{ brand: localBrand, value: 100 },
{ brand: localBrand, value: 100000000000000000001n },
'we received the shadow atoms',
);

Expand Down
56 changes: 30 additions & 26 deletions demo/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
// Until that time, this allows contract developers to add their
// issuer and purse to an individual wallet.

import dappConstants from '../ui.old/public/conf/defaults';
import { E } from '@agoric/eventual-send';
import { assert, details } from '@agoric/assert';
import dappConstants from '../ui.old/public/conf/defaults';

// deploy.js runs in an ephemeral Node.js outside of swingset. The
// spawner runs within ag-solo, so is persistent. Once the deploy.js
// script ends, connections to any of its objects are severed.

// The contract's registry key for the assurance issuer.
const {
INSTANCE_BOARD_ID,
} = dappConstants;
const { INSTANCE_BOARD_ID } = dappConstants;

/**
* @typedef {Object} DeployPowers The special powers that `agoric deploy` gives us
Expand All @@ -29,56 +27,59 @@ const {
* available from REPL home
* @param {DeployPowers} powers
*/
export default async function deployTransfer(homePromise, { bundleSource, pathResolve }) {

export default async function deployTransfer(
homePromise,
{ bundleSource, pathResolve },
) {
// Let's wait for the promise to resolve.
const home = await homePromise;

// Unpack the home references.
const {

const {
// *** LOCAL REFERENCES ***

// This wallet only exists on this machine, and only you have
// access to it. The wallet stores purses and handles transactions.
wallet,
wallet,

spawner,

// *** ON-CHAIN REFERENCES ***

board,

zoe,
} = home;

const instance = await E(board).getValue(INSTANCE_BOARD_ID);

/**
* @type {import('../contract/src/pegasus').Pegasus}
*/
const pegasus = await E(zoe).getPublicFacet(instance);

const notifier = await E(pegasus).getNotifier();
const { value } = await E(notifier).getUpdateSince();

// FIXME: Don't just select the last peg.
/** @type {import('../contract/src/pegasus').Peg} */
const peg = value[value.length - 1];
const extent = JSON.parse(process.env.VALUE || '0')

const extent = BigInt(process.env.VALUE || '0');
let pursePetname = process.env.PURSE || "Bob's Atoms";
try {
pursePetname = JSON.parse(pursePetname);
} catch (e) {
// nothing
}
const RECEIVER = process.env.RECEIVER
const { RECEIVER } = process.env;

assert(RECEIVER, details`$RECEIVER must be set`);

const invitation = await E(pegasus).makeInvitationToTransfer(peg, RECEIVER);
const invitationAmount = await E(E(zoe).getInvitationIssuer()).getAmountOf(invitation);
const invitationAmount = await E(E(zoe).getInvitationIssuer()).getAmountOf(
invitation,
);
const {
value: [{ handle: invitationHandle }],
} = invitationAmount;
Expand All @@ -105,7 +106,10 @@ export default async function deployTransfer(homePromise, { bundleSource, pathRe
},
};

await E(wallet).addOffer(offer, { date: Date.now(), origin: 'https://peg-as.us', });
await E(wallet).addOffer(offer, {
date: Date.now(),
origin: 'https://peg-as.us',
});

// We are done!
console.log('Proposed transfer; check your wallet!');
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@
resolved "https://registry.yarnpkg.com/@agoric/nat/-/nat-2.0.1.tgz#28aba18367deba354bdd424bdf6daa48f5e7d37f"
integrity sha512-puvWkoaJovQib/YaSRSGJ8Kn9rogi/yyaVa3d5znSZb5WiYfUiEKW35BfexHhAdi0VfPz2anFHoRBoBSUIijNA==

"@agoric/nat@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@agoric/nat/-/nat-4.0.0.tgz#330dcde37fcf8882dbc5012a3b2c4c135eee4930"
integrity sha512-zlTe14g0PGfONO0+TdhLv8k4IZH040ojvBZuNrcQSV+l8HlFTZ/IKzI5HorlCVDDBU7riykAb/6MaTgMRbYp3w==

"@agoric/notifier@*", "@agoric/notifier@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@agoric/notifier/-/notifier-0.3.0.tgz#493008dc4ed302d314be573a4f6e80a97b289d47"
Expand Down

0 comments on commit 037e2f7

Please sign in to comment.