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

ABI generation #301

Merged
merged 15 commits into from
Dec 4, 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 examples/src/parking-lot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ParkingLot {
}

@view({})
getCarSpecs({ name }: { name: string }) {
getCarSpecs({ name }: { name: string }): CarSpecs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we get warnings (or configure tsconfig in a way) when method doesn't have return type?

near.log(`getCarSpecs() called, name: ${name}`);
return this.cars.get(name);
}
Expand Down
8 changes: 5 additions & 3 deletions examples/src/standard-nft/test-approval-receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
PromiseOrValue,
assert,
call,
bytes,
serialize,
} from "near-sdk-js";
import { AccountId } from "near-sdk-js";
import { NonFungibleTokenApprovalReceiver } from "near-contract-standards/lib/non_fungible_token/approval/approval_receiver";
Expand All @@ -15,7 +17,7 @@ const PROMISE_CALL = 20_000_000_000_000n;
const GAS_FOR_NFT_ON_APPROVE = BASE_GAS + PROMISE_CALL;

interface ValueReturnInterface {
ok_go(msg: string): PromiseOrValue<string>;
ok_go({ msg }: { msg: string }): PromiseOrValue<string>;
}

@NearBindgen({ requireInit: true })
Expand Down Expand Up @@ -56,7 +58,7 @@ export class ApprovalReceiver
const account_id = near.currentAccountId();
return NearPromise.new(account_id).functionCall(
"ok_go",
JSON.stringify(msg),
bytes(serialize({ msg })),
0n,
prepaid_gas - GAS_FOR_NFT_ON_APPROVE
);
Expand All @@ -65,7 +67,7 @@ export class ApprovalReceiver
}

@call({})
ok_go(msg: string): PromiseOrValue<string> {
ok_go({ msg }: { msg: string }): PromiseOrValue<string> {
near.log(`in ok_go, msg=${msg}`);
return msg;
}
Expand Down
10 changes: 6 additions & 4 deletions examples/src/standard-nft/test-token-receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
NearBindgen,
NearPromise,
PromiseOrValue,
bytes,
serialize,
} from "near-sdk-js";
import { AccountId } from "near-sdk-js";

Expand All @@ -15,7 +17,7 @@ const PROMISE_CALL = 10_000_000_000_000n;
const GAS_FOR_NFT_ON_TRANSFER = BASE_GAS + PROMISE_CALL;

interface ValueReturnInterface {
ok_go(return_it: boolean): PromiseOrValue<boolean>;
ok_go({ return_it }: { return_it: boolean }): PromiseOrValue<boolean>;
}

@NearBindgen({ requireInit: true })
Expand Down Expand Up @@ -64,7 +66,7 @@ export class TokenReceiver
const account_id = near.currentAccountId();
return NearPromise.new(account_id).functionCall(
"ok_go",
JSON.stringify(true),
bytes(serialize({ return_it: true })),
0n,
prepaid_gas - GAS_FOR_NFT_ON_TRANSFER
);
Expand All @@ -76,7 +78,7 @@ export class TokenReceiver
const account_id = near.currentAccountId();
return NearPromise.new(account_id).functionCall(
"ok_go",
JSON.stringify(false),
bytes(serialize({ return_it: false })),
0n,
prepaid_gas - GAS_FOR_NFT_ON_TRANSFER
);
Expand All @@ -87,7 +89,7 @@ export class TokenReceiver
}

@call({})
ok_go(return_it: boolean): PromiseOrValue<boolean> {
ok_go({ return_it }: { return_it: boolean }): PromiseOrValue<boolean> {
near.log(`in ok_go, return_it=${return_it}`);
return return_it;
}
Expand Down
976 changes: 585 additions & 391 deletions examples/yarn.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/cli/abi.d.ts

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

210 changes: 210 additions & 0 deletions lib/cli/abi.js

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

5 changes: 4 additions & 1 deletion lib/cli/cli.d.ts

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

21 changes: 20 additions & 1 deletion lib/cli/cli.js

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

1 change: 1 addition & 0 deletions lib/version.d.ts

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

4 changes: 4 additions & 0 deletions lib/version.js

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

Loading