Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(contract): modify to work with agoric-upgrade-16 #7

Closed
wants to merge 10 commits into from
Closed
14 changes: 8 additions & 6 deletions .github/workflows/contract-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
node-version: [18.x]
steps:
- name: Checkout dapp
uses: actions/checkout@v2
uses: actions/checkout@v4

# Select a branch on agoric-sdk to test against by adding text to the body of the
# pull request. For example: #agoric-sdk-branch: zoe-release-0.7.0
# The default is 'master'
- name: Get the appropriate agoric-sdk branch
id: get-branch
uses: actions/github-script@0.9.0
uses: actions/github-script@v7
with:
result-encoding: string
script: |
Expand All @@ -34,14 +34,14 @@ jobs:
return agoricSdkBranch;

- name: Checkout agoric-sdk
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: schnetzlerjoe/agoric-sdk
repository: Agoric/agoric-sdk
path: agoric-sdk
ref: ${{steps.get-branch.outputs.result}}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -55,6 +55,8 @@ jobs:

- name: agoric install
run: agoric install
- name: yarn lint-check
run: yarn lint-check
- name: yarn build
run: yarn build
- name: yarn test (everything)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ const res = await E(instance.publicFacet).sendICATxPacket(
connection,
);
```

## How to upgrade Agoric package resolutions

Run `agoric-sdk/scripts/upgrade-agoric-resolutions.sh` within this directory.
3 changes: 2 additions & 1 deletion contract/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"module": "NodeNext",
},
"include": ["src/**/*.js", "test/**/*.js", "exported.js", "globals.d.ts"],
}
34 changes: 22 additions & 12 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
"type": "module",
"scripts": {
"build": "exit 0",
"test": "npx ava --verbose",
"test": "ava --verbose",
"lint": "eslint '**/*.{js,jsx}'",
"lint-fix": "eslint --fix '**/*.{js,jsx}'",
"lint-check": "eslint '**/*.{js,jsx}'",
"lint-fix-jessie": "eslint -c '.eslintrc-jessie.js' --fix '**/*.{js,jsx}'",
"lint-check-jessie": "eslint -c '.eslintrc-jessie.js' '**/*.{js,jsx}'"
},
"devDependencies": {
"ava": "^3.13.0",
"eslint": "^7.23.0",
"ava": "^6.1.3",
"@endo/ses-ava": "^1.2.2",
"eslint": "^8.50.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-jessie": "^0.0.6",
"eslint-config-prettier": "^6.12.0",
Expand All @@ -24,19 +25,23 @@
"prettier": "^2.1.2"
},
"dependencies": {
"@agoric/cosmic-proto": "calypso-dev",
"@agoric/assert": "agoric-upgrade-16",
"@agoric/deploy-script-support": "agoric-upgrade-16",
"@agoric/ertp": "agoric-upgrade-16",
"@agoric/network": "agoric-upgrade-16",
"@agoric/notifier": "agoric-upgrade-16",
"@agoric/store": "agoric-upgrade-16",
"@agoric/zoe": "agoric-upgrade-16",
"@agoric/zone": "agoric-upgrade-16",
"@agoric/vow": "agoric-upgrade-16",
"@agoric/babel-standalone": "^7.17.7",
"@endo/bundle-source": "^2.1.1",
"@endo/base64": "^0.2.30",
"@agoric/assert": "beta",
"@agoric/deploy-script-support": "beta",
"@agoric/ertp": "beta",
"@endo/far": "^1.1.2",
"@endo/eventual-send": "^0.14.8",
"@endo/init": "^0.5.37",
"@endo/marshal": "^0.6.9",
"@agoric/notifier": "beta",
"@agoric/store": "beta",
"@agoric/zoe": "beta",
"@agoric/babel-standalone": "^7.17.7",
"@agoric/swingset-vat": "beta",
"@cosmjs/encoding": "^0.28.4",
"@endo/promise-kit": "^0.2.42",
"cosmjs-types": "agoric-labs/cosmjs-types#Agoric-built"
Expand Down Expand Up @@ -64,7 +69,12 @@
"eslintConfig": {
"extends": [
"@agoric"
]
],
"settings": {
"jsdoc": {
"definedTags": ["import"]
}
}
},
"prettier": {
"trailingComma": "all",
Expand Down
58 changes: 39 additions & 19 deletions contract/src/contract.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,59 @@
// @ts-check
/* global harden */
import '@agoric/zoe/exported.js';
import { Far } from '@endo/marshal';
import { ICS27ICAProtocol } from './ica.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { M } from '@agoric/store';
import { MessageShape, prepareICS27ICAProtocol } from './ica.js';

/**
*
* @type {ContractStartFn}
* @param {unknown} _zcf
* @param {unknown} _pa
* @param {import('@agoric/swingset-liveslots').Baggage} baggage
*/
const start = () => {
const creatorFacet = Far('creatorFacet', {
// The creator of the instance can be called by the creator
const start = (_zcf, _pa, baggage) => {
const zone = makeDurableZone(baggage);

const makeICS27ICAProtocol = prepareICS27ICAProtocol(zone);
const ICS27ICAProtocol = makeICS27ICAProtocol();

const PublicFacetGuard = M.interface('ICS27ICA', {
createICAAccount:
M.call(M.remotable('port'), M.any(), M.string(), M.string())
.returns(M.promise()),
sendICATxPacket: M.call(M.arrayOf(MessageShape), M.any()).returns(M.promise()),
});

const publicFacet = Far('publicFacet', {
/** @type {import('./types.js').ICA} */
const publicFacet = zone.exo('publicFacet', PublicFacetGuard, {
// Public faucet for anyone to call
/**
* @param {import('@agoric/network').Port} port
* @param {object} connectionHandler
* @param {string} controllerConnectionId
* @param {string} hostConnectionId
*/
createICAAccount: (
/** @type {Port} */ port,
/** @type {object} */ connectionHandler,
/** @type {string} */ controllerConnectionId,
/** @type {string} */ hostConnectionId,
port,
connectionHandler,
controllerConnectionId,
hostConnectionId,
) =>
ICS27ICAProtocol.createICS27Account(
ICS27ICAProtocol.createICAAccount(
port,
connectionHandler,
controllerConnectionId,
hostConnectionId,
),

/**
* @param {import('./types.js').Msg[]} msgs
* @param {import('@agoric/network').Connection} connection
*/
sendICATxPacket: (
/** @type {[Msg]} */ msgs,
/** @type {Connection} */ connection,
) => ICS27ICAProtocol.sendICATx(msgs, connection),
msgs,
connection,
) => ICS27ICAProtocol.sendICAPacket(msgs, connection),
});

return harden({ creatorFacet, publicFacet });
return harden({ publicFacet });
};

harden(start);
Expand Down
Loading
Loading