/
near.go
140 lines (116 loc) · 4.51 KB
/
near.go
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package mapprotocol
import (
"math/big"
"github.com/mapprotocol/near-api-go/pkg/client"
"github.com/mapprotocol/near-api-go/pkg/types"
"github.com/mapprotocol/near-api-go/pkg/types/hash"
"github.com/mapprotocol/near-api-go/pkg/types/key"
"github.com/mapprotocol/near-api-go/pkg/types/signature"
)
const (
TransferOut = "transfer out"
DepositOut = "deposit out"
)
type StreamerMessage struct {
Block client.BlockView `json:"block"`
Shards []IndexerShard `json:"shards"`
}
type IndexerShard struct {
Chunk *IndexerChunkView `json:"chunk"`
ReceiptExecutionOutcomes []IndexerExecutionOutcomeWithReceipt `json:"receipt_execution_outcomes"`
ShardID types.ShardID `json:"shard_id"`
StateChanges StateChangesView `json:"state_changes"`
}
type IndexerChunkView struct {
Author types.AccountID `json:"author"`
Header client.ChunkHeaderView `json:"header"`
Receipts []ReceiptView `json:"receipts"`
//Transactions []IndexerTransactionWithOutcome `json:"transactions"`
}
type ReceiptView struct {
PredecessorId types.AccountID `json:"predecessor_id"`
ReceiverID types.AccountID `json:"receiver_id"`
ReceiptID hash.CryptoHash `jsom:"receipt_id"`
Receipt Receipt `json:"receipt"`
}
type Receipt struct {
Action Action `json:"Action"`
}
type Action struct {
Actions []interface{} `json:"actions"` //
//Actions []map[string]interface{} `json:"actions"` //
GasPrice string `json:"gas_price"`
InputDataIds []interface{} `json:"input_data_ids"`
OutputDataReceivers []interface{} `json:"output_data_receivers"`
SignerID string `json:"signer_id"`
SignerPublicKey string `json:"signer_public_key"`
}
type IndexerTransactionWithOutcome struct {
Outcome IndexerExecutionOutcomeWithOptionalReceipt `json:"outcome"`
Transaction SignedTransactionView `json:"transaction"`
}
type SignedTransactionView struct {
SignerID types.AccountID `json:"signer_id"`
PublicKey key.Base58PublicKey `json:"public_key"`
Nonce types.Nonce `json:"nonce"`
ReceiverID types.AccountID `json:"receiver_id"`
Actions []interface{} `json:"actions"`
Signature signature.Base58Signature `json:"signature"`
Hash hash.CryptoHash `json:"hash"`
}
type IndexerExecutionOutcomeWithReceipt struct {
ExecutionOutcome ExecutionOutcomeWithIdView `json:"execution_outcome"`
Receipt ReceiptView `json:"receipt"`
}
type ExecutionOutcomeWithIdView struct {
BlockHash hash.CryptoHash `json:"block_hash"`
ID hash.CryptoHash `json:"id"`
Outcome ExecutionOutcomeView `json:"outcome"`
Proof MerklePath `json:"proof"`
}
type ExecutionOutcomeView struct {
ExecutorID types.AccountID `json:"executor_id"`
GasBurnt types.Gas `json:"gas_burnt"`
Logs []string `json:"logs"`
Metadata Metadata `json:"metadata"`
ReceiptIDs []hash.CryptoHash `json:"receipt_ids"`
Status client.TransactionStatus `json:"status"`
TokensBurnt string `json:"tokens_burnt"` // "242953087248000000000"
}
type MerklePathItem struct {
Hash hash.CryptoHash `json:"hash"`
Direction string `json:"direction"`
}
type MerklePath = []MerklePathItem
type IndexerExecutionOutcomeWithOptionalReceipt struct {
ExecutionOutcome ExecutionOutcomeWithIdView `json:"execution_outcome"`
Receipt *client.ReceiptView `json:"receipt"`
}
type StateChangesView []StateChangeWithCauseView
type StateChangeWithCauseView struct {
Type TypeOfStateChange `json:"type"`
Cause StateChangeCauseView `json:"cause"`
Change StateChangeView `json:"change"`
// Value StateChangeValueView `json:"value"`
}
type StateChangeCauseView struct {
ReceiptHash string `json:"receipt_hash"`
Type string `json:"type"`
}
type StateChangeView struct {
AccountId types.AccountID `json:"account_id"`
Amount string `json:"amount"`
CodeHash string `json:"code_hash"`
Locked string `json:"locked"`
StoragePaidAt int64 `json:"storage_paid_at"`
StorageUsage int64 `json:"storage_usage"`
CodeBase64 string `json:"code_base_64"`
}
type AccessKey struct {
Nonce *big.Int
Permission string
}
// type StateChangeValueView json.RawMessage
type (
TypeOfStateChange string
)