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

Workspaces 3.1.0 #151

Merged
merged 6 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/standalone-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
examples:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
platform: [ubuntu-latest] # macos-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 1 addition & 4 deletions examples/__tests__/test-clean-state.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the clean-state contract.
const cleanState = await root.createAndDeploy(
root.getSubAccount('cleanstate').accountId,
'./build/clean-state.wasm',
);
const cleanState = await root.devDeploy('./build/clean-state.wasm');

// Init the contract
await cleanState.call(cleanState, 'init', {});
Expand Down
3 changes: 1 addition & 2 deletions examples/__tests__/test-counter.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the counter contract.
const counter = await root.createAndDeploy(
root.getSubAccount('counter').accountId,
const counter = await root.devDeploy(
process.env['COUNTER_LOWLEVEL'] ?
'./build/counter-lowlevel.wasm' :
(process.env['COUNTER_TS'] ? './build/counter-ts.wasm' : './build/counter.wasm')
Expand Down
19 changes: 8 additions & 11 deletions examples/__tests__/test-cross-contract-call.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@ test.beforeEach(async t => {
// Prepare sandbox for tests, create accounts, deploy contracts, etx.
const root = worker.rootAccount;

// Deploy the onCall contract.
const onCall = await root.createAndDeploy(
root.getSubAccount('oncall').accountId,
'./build/cross-contract-call.wasm',
// Deploy status-message the contract.
const statusMessage = await root.devDeploy(
'./build/status-message.wasm',
);

// Init the contract
await onCall.call(onCall, 'init', {});
await statusMessage.call(statusMessage, 'init', {});

// Deploy status-message the contract.
const statusMessage = await root.createAndDeploy(
root.getSubAccount('statusmessage').accountId,
'./build/status-message.wasm',
// Deploy the onCall contract.
const onCall = await root.devDeploy(
'./build/cross-contract-call.wasm',
);

// Init the contract
await statusMessage.call(statusMessage, 'init', {});
await onCall.call(onCall, 'init', { statusMessageContract: statusMessage.accountId });

// Create test accounts
const ali = await root.createSubAccount('ali');
Expand Down Expand Up @@ -61,7 +59,6 @@ test('Person can be set on-call if AVAILABLE', async t => {
// Bob sets Ali on-call
await bob.call(onCall, 'set_person_on_call', { accountId: ali.accountId }, { gas: 120000000000000 });


// Check that Ali is on-call
t.is(
await onCall.view('person_on_call', {}),
Expand Down
3 changes: 1 addition & 2 deletions examples/__tests__/test-fungible-token-lockable.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the lockable-ft contract.
const lockableFt = await root.createAndDeploy(
root.getSubAccount('lockableft').accountId,
const lockableFt = await root.devDeploy(
'./build/fungible-token-lockable.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions examples/__tests__/test-fungible-token.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the ft contract.
const ft = await root.createAndDeploy(
root.getSubAccount('ft').accountId,
const ft = await root.devDeploy(
'./build/fungible-token.wasm',
);

Expand Down
6 changes: 2 additions & 4 deletions examples/__tests__/test-non-fungible-token.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the nft contract.
const nft = await root.createAndDeploy(
root.getSubAccount('nft').accountId,
const nft = await root.devDeploy(
'./build/non-fungible-token.wasm',
);

// Init the contract
await nft.call(nft, 'init', { owner_id: nft.accountId, owner_by_id_prefix: 'a' });

// Deploy the tokenReceiver contract.
const tokenReceiver = await root.createAndDeploy(
root.getSubAccount('tokenreceiver').accountId,
const tokenReceiver = await root.devDeploy(
'./build/non-fungible-token-receiver.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions examples/__tests__/test-status-message-collections.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the statis-message contract.
const statusMessage = await root.createAndDeploy(
root.getSubAccount('statusmessage').accountId,
const statusMessage = await root.devDeploy(
'./build/status-message-collections.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions examples/__tests__/test-status-message.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ test.before(async t => {
const root = worker.rootAccount;

// Deploy the contract.
const statusMessage = await root.createAndDeploy(
root.getSubAccount('statusmessage').accountId,
const statusMessage = await root.devDeploy(
'./build/status-message.wasm',
);

Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"devDependencies": {
"ava": "^4.2.0",
"near-workspaces": "2.0.0",
"near-workspaces": "3.1.0",
"typescript": "^4.7.4"
}
}
5 changes: 3 additions & 2 deletions examples/src/cross-contract-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { NearContract, NearBindgen, call, view, near, bytes } from 'near-sdk-js'

@NearBindgen
class OnCall extends NearContract {
constructor({ }) {
constructor({ statusMessageContract }) {
super()
this.personOnCall = "undefined"
this.statusMessageContract = statusMessageContract
}

@call
set_person_on_call({ accountId }) {
near.log(`Trying to set ${accountId} on-call`)
const promise = near.promiseBatchCreate('statusmessage.test.near')
const promise = near.promiseBatchCreate(this.statusMessageContract)
near.promiseBatchActionFunctionCall(promise, 'get_status', bytes(JSON.stringify({ account_id: accountId })), 0, 30000000000000)
near.promiseThen(promise, near.currentAccountId(), '_set_person_on_call_private', bytes(JSON.stringify({ accountId: accountId })), 0, 30000000000000);
}
Expand Down
20 changes: 10 additions & 10 deletions examples/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions jsvm/examples/__tests__/test-clean-state.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/examples/__tests__/test-counter.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/examples/__tests__/test-cross-contract-call.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/examples/__tests__/test-fungible-token.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/examples/__tests__/test-non-fungible-token.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/examples/__tests__/test-status-message.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.before(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'./node_modules/near-sdk-js/jsvm/build/jsvm.wasm',
);

Expand Down
2 changes: 1 addition & 1 deletion jsvm/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"devDependencies": {
"ava": "^4.2.0",
"near-workspaces": "^2.0.0"
"near-workspaces": "^3.0.0"
}
}
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/bytes.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/function-params.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/lookup-map.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/lookup-set.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/unordered-map.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/unordered-set.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
3 changes: 1 addition & 2 deletions jsvm/tests/__tests__/vector.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the jsvm contract.
const jsvm = await root.createAndDeploy(
root.getSubAccount('jsvm').accountId,
const jsvm = await root.devDeploy(
'../../jsvm/build/jsvm.wasm',
);

Expand Down
2 changes: 1 addition & 1 deletion jsvm/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},
"devDependencies": {
"ava": "^4.2.0",
"near-workspaces": "^2.0.0"
"near-workspaces": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion lib/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ export declare function promiseResult(resultIdx: number | BigInt): Bytes | Promi
export declare function promiseReturn(promiseIdx: number | BigInt): void;
export declare function storageWrite(key: Bytes, value: Bytes): boolean;
export declare function storageRemove(key: Bytes): boolean;
export declare function storage_byte_cost(): BigInt;
export declare function storageByteCost(): BigInt;
2 changes: 1 addition & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,6 @@ export function storageRemove(key) {
}
return false;
}
export function storage_byte_cost() {
export function storageByteCost() {
return 10000000000000000000n;
}
3 changes: 1 addition & 2 deletions tests/__tests__/bytes.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the test contract.
const bytesContract = await root.createAndDeploy(
root.getSubAccount('test-contract').accountId,
const bytesContract = await root.devDeploy(
'build/bytes.wasm',
);
// Test users
Expand Down
Loading