Skip to content

Commit eea0b76

Browse files
authored
Merge branch 'master' into add_deprecation_warnings
2 parents 3cb19c4 + 03325ac commit eea0b76

File tree

14 files changed

+3825
-14
lines changed

14 files changed

+3825
-14
lines changed

.changeset/happy-points-shop.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"near-api-js": minor
3+
"@near-js/accounts": minor
4+
---
5+
6+
Introduce `TypedContract` with type-safe ABI support

e2e/contracts/guestbook/abi.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import type { AbiRoot } from "@near-js/accounts";
2+
3+
export const abi = {
4+
schema_version: "0.4.0",
5+
metadata: {
6+
name: "contract",
7+
version: "0.1.0",
8+
build: {
9+
compiler: "rustc 1.86.0",
10+
builder: "cargo-near cargo-near-build 0.7.2",
11+
},
12+
wasm_hash: "EmTQGUyEmTpd6BigmqBtYqZcX9ps8zJ48UPQHSc16vm9",
13+
},
14+
body: {
15+
functions: [
16+
{
17+
name: "add_message",
18+
kind: "call",
19+
modifiers: ["payable"],
20+
params: {
21+
serialization_type: "json",
22+
args: [
23+
{
24+
name: "text",
25+
type_schema: {
26+
type: "string",
27+
},
28+
},
29+
],
30+
},
31+
},
32+
{
33+
name: "contract_source_metadata",
34+
kind: "view",
35+
},
36+
{
37+
name: "get_messages",
38+
kind: "view",
39+
params: {
40+
serialization_type: "json",
41+
args: [
42+
{
43+
name: "from_index",
44+
type_schema: {
45+
type: ["string", "null"],
46+
},
47+
},
48+
{
49+
name: "limit",
50+
type_schema: {
51+
type: ["string", "null"],
52+
},
53+
},
54+
],
55+
},
56+
result: {
57+
serialization_type: "json",
58+
type_schema: {
59+
type: "array",
60+
items: {
61+
$ref: "#/definitions/PostedMessage",
62+
},
63+
},
64+
},
65+
},
66+
{
67+
name: "total_messages",
68+
kind: "view",
69+
result: {
70+
serialization_type: "json",
71+
type_schema: {
72+
type: "integer",
73+
format: "uint32",
74+
minimum: 0.0,
75+
},
76+
},
77+
},
78+
],
79+
root_schema: {
80+
$schema: "http://json-schema.org/draft-07/schema#",
81+
title: "String",
82+
type: "string",
83+
definitions: {
84+
AccountId: {
85+
description:
86+
'NEAR Account Identifier.\n\nThis is a unique, syntactically valid, human-readable account identifier on the NEAR network.\n\n[See the crate-level docs for information about validation.](index.html#account-id-rules)\n\nAlso see [Error kind precedence](AccountId#error-kind-precedence).\n\n## Examples\n\n``` use near_account_id::AccountId;\n\nlet alice: AccountId = "alice.near".parse().unwrap();\n\nassert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```',
87+
type: "string",
88+
},
89+
PostedMessage: {
90+
type: "object",
91+
required: ["premium", "sender", "text"],
92+
properties: {
93+
premium: {
94+
type: "boolean",
95+
},
96+
sender: {
97+
$ref: "#/definitions/AccountId",
98+
},
99+
text: {
100+
type: "string",
101+
},
102+
},
103+
},
104+
},
105+
},
106+
},
107+
} as const satisfies AbiRoot;
115 KB
Binary file not shown.

0 commit comments

Comments
 (0)