forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathescrow.json
More file actions
94 lines (94 loc) · 3.74 KB
/
Copy pathescrow.json
File metadata and controls
94 lines (94 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{
"contract": "escrow",
"version": "1.0.0",
"description": "Time-locked escrow for conditional token releases.",
"functions": [
{
"name": "initialize",
"description": "Initializes the escrow contract.",
"params": [{ "name": "admin", "type": "Address" }],
"returns": null,
"errors": ["already initialized"]
},
{
"name": "create",
"description": "Creates a new escrow.",
"params": [
{ "name": "depositor", "type": "Address" },
{ "name": "beneficiary", "type": "Address" },
{ "name": "token", "type": "Address" },
{ "name": "amount", "type": "i128" },
{ "name": "timeout_ledger", "type": "u32", "description": "Ledger after which depositor can refund." }
],
"returns": { "type": "u32", "description": "Escrow ID." },
"errors": ["amount must be positive"]
},
{
"name": "fund",
"description": "Funds an existing escrow.",
"params": [
{ "name": "escrow_id", "type": "u32" },
{ "name": "from", "type": "Address" }
],
"returns": null,
"errors": ["not found", "already funded"]
},
{
"name": "release",
"description": "Releases escrowed tokens to the beneficiary. Admin only.",
"params": [{ "name": "escrow_id", "type": "u32" }],
"returns": null,
"errors": ["unauthorized", "not funded", "already released", "already refunded"]
},
{
"name": "refund",
"description": "Refunds escrowed tokens to the depositor after timeout.",
"params": [
{ "name": "escrow_id", "type": "u32" },
{ "name": "depositor", "type": "Address" }
],
"returns": null,
"errors": ["unauthorized", "not funded", "timeout not reached", "already released", "already refunded"]
},
{
"name": "get",
"description": "Returns escrow details.",
"params": [{ "name": "escrow_id", "type": "u32" }],
"returns": { "type": "Escrow" },
"errors": ["not found"]
}
],
"types": {
"EscrowStatus": {
"variants": ["Pending", "Funded", "Released", "Refunded"]
},
"Escrow": {
"fields": [
{ "name": "id", "type": "u32" },
{ "name": "depositor", "type": "Address" },
{ "name": "beneficiary", "type": "Address" },
{ "name": "token", "type": "Address" },
{ "name": "amount", "type": "i128" },
{ "name": "timeout_ledger", "type": "u32" },
{ "name": "status", "type": "EscrowStatus" }
]
}
},
"events": [
{ "name": "escrow_created", "fields": [{ "name": "id", "type": "u32" }, { "name": "depositor", "type": "Address" }, { "name": "beneficiary", "type": "Address" }] },
{ "name": "escrow_funded", "fields": [{ "name": "id", "type": "u32" }] },
{ "name": "escrow_released", "fields": [{ "name": "id", "type": "u32" }, { "name": "beneficiary", "type": "Address" }] },
{ "name": "escrow_refunded", "fields": [{ "name": "id", "type": "u32" }, { "name": "depositor", "type": "Address" }] }
],
"errors": [
{ "code": 1, "name": "AlreadyInitialized", "message": "already initialized" },
{ "code": 2, "name": "Unauthorized", "message": "unauthorized" },
{ "code": 3, "name": "NotFound", "message": "escrow not found" },
{ "code": 4, "name": "AlreadyFunded", "message": "already funded" },
{ "code": 5, "name": "NotFunded", "message": "escrow not funded" },
{ "code": 6, "name": "AlreadyReleased", "message": "already released" },
{ "code": 7, "name": "AlreadyRefunded", "message": "already refunded" },
{ "code": 8, "name": "TimeoutNotReached", "message": "timeout ledger not reached" },
{ "code": 9, "name": "AmountMustBePositive", "message": "amount must be positive" }
]
}