xpring 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/org/xrpl/rpc/v1/account_pb.rb +22 -0
- data/lib/org/xrpl/rpc/v1/amount_pb.rb +41 -0
- data/lib/org/xrpl/rpc/v1/common_pb.rb +341 -0
- data/lib/org/xrpl/rpc/v1/get_account_info_pb.rb +57 -0
- data/lib/org/xrpl/rpc/v1/get_account_transaction_history_pb.rb +48 -0
- data/lib/org/xrpl/rpc/v1/get_fee_pb.rb +46 -0
- data/lib/org/xrpl/rpc/v1/get_transaction_pb.rb +43 -0
- data/lib/org/xrpl/rpc/v1/ledger_objects_pb.rb +208 -0
- data/lib/org/xrpl/rpc/v1/ledger_pb.rb +38 -0
- data/lib/org/xrpl/rpc/v1/meta_pb.rb +67 -0
- data/lib/org/xrpl/rpc/v1/submit_pb.rb +31 -0
- data/lib/org/xrpl/rpc/v1/transaction_pb.rb +199 -0
- data/lib/org/xrpl/rpc/v1/xrp_ledger_pb.rb +23 -0
- data/lib/org/xrpl/rpc/v1/xrp_ledger_services_pb.rb +37 -0
- data/lib/xpring.rb +28 -0
- data/lib/xpring/client.rb +120 -0
- data/lib/xpring/error.rb +6 -0
- data/lib/xpring/javascript.rb +63 -0
- data/lib/xpring/javascript/library.js +28 -0
- data/lib/xpring/signer.rb +25 -0
- data/lib/xpring/util.rb +82 -0
- data/lib/xpring/version.rb +5 -0
- data/lib/xpring/wallet.rb +106 -0
- metadata +169 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: org/xrpl/rpc/v1/submit.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'org/xrpl/rpc/v1/meta_pb'
|
7
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
8
|
+
add_file("org/xrpl/rpc/v1/submit.proto", :syntax => :proto3) do
|
9
|
+
add_message "org.xrpl.rpc.v1.SubmitTransactionRequest" do
|
10
|
+
optional :signed_transaction, :bytes, 1
|
11
|
+
optional :fail_hard, :bool, 2
|
12
|
+
end
|
13
|
+
add_message "org.xrpl.rpc.v1.SubmitTransactionResponse" do
|
14
|
+
optional :engine_result, :message, 1, "org.xrpl.rpc.v1.TransactionResult"
|
15
|
+
optional :engine_result_code, :int64, 2
|
16
|
+
optional :engine_result_message, :string, 3
|
17
|
+
optional :hash, :bytes, 4
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Org
|
23
|
+
module Xrpl
|
24
|
+
module Rpc
|
25
|
+
module V1
|
26
|
+
SubmitTransactionRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.SubmitTransactionRequest").msgclass
|
27
|
+
SubmitTransactionResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.SubmitTransactionResponse").msgclass
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: org/xrpl/rpc/v1/transaction.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'org/xrpl/rpc/v1/common_pb'
|
7
|
+
require 'org/xrpl/rpc/v1/amount_pb'
|
8
|
+
require 'org/xrpl/rpc/v1/account_pb'
|
9
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
10
|
+
add_file("org/xrpl/rpc/v1/transaction.proto", :syntax => :proto3) do
|
11
|
+
add_message "org.xrpl.rpc.v1.Transaction" do
|
12
|
+
optional :account, :message, 1, "org.xrpl.rpc.v1.Account"
|
13
|
+
optional :fee, :message, 2, "org.xrpl.rpc.v1.XRPDropsAmount"
|
14
|
+
optional :sequence, :message, 3, "org.xrpl.rpc.v1.Sequence"
|
15
|
+
optional :signing_public_key, :message, 5, "org.xrpl.rpc.v1.SigningPublicKey"
|
16
|
+
optional :transaction_signature, :message, 6, "org.xrpl.rpc.v1.TransactionSignature"
|
17
|
+
optional :flags, :message, 7, "org.xrpl.rpc.v1.Flags"
|
18
|
+
optional :last_ledger_sequence, :message, 8, "org.xrpl.rpc.v1.LastLedgerSequence"
|
19
|
+
optional :source_tag, :message, 9, "org.xrpl.rpc.v1.SourceTag"
|
20
|
+
repeated :memos, :message, 10, "org.xrpl.rpc.v1.Memo"
|
21
|
+
repeated :signers, :message, 11, "org.xrpl.rpc.v1.Signer"
|
22
|
+
optional :account_transaction_id, :message, 12, "org.xrpl.rpc.v1.AccountTransactionID"
|
23
|
+
oneof :transaction_data do
|
24
|
+
optional :payment, :message, 4, "org.xrpl.rpc.v1.Payment"
|
25
|
+
optional :account_set, :message, 13, "org.xrpl.rpc.v1.AccountSet"
|
26
|
+
optional :account_delete, :message, 14, "org.xrpl.rpc.v1.AccountDelete"
|
27
|
+
optional :check_cancel, :message, 15, "org.xrpl.rpc.v1.CheckCancel"
|
28
|
+
optional :check_cash, :message, 16, "org.xrpl.rpc.v1.CheckCash"
|
29
|
+
optional :check_create, :message, 17, "org.xrpl.rpc.v1.CheckCreate"
|
30
|
+
optional :deposit_preauth, :message, 18, "org.xrpl.rpc.v1.DepositPreauth"
|
31
|
+
optional :escrow_cancel, :message, 19, "org.xrpl.rpc.v1.EscrowCancel"
|
32
|
+
optional :escrow_create, :message, 20, "org.xrpl.rpc.v1.EscrowCreate"
|
33
|
+
optional :escrow_finish, :message, 21, "org.xrpl.rpc.v1.EscrowFinish"
|
34
|
+
optional :offer_cancel, :message, 22, "org.xrpl.rpc.v1.OfferCancel"
|
35
|
+
optional :offer_create, :message, 23, "org.xrpl.rpc.v1.OfferCreate"
|
36
|
+
optional :payment_channel_claim, :message, 24, "org.xrpl.rpc.v1.PaymentChannelClaim"
|
37
|
+
optional :payment_channel_create, :message, 25, "org.xrpl.rpc.v1.PaymentChannelCreate"
|
38
|
+
optional :payment_channel_fund, :message, 26, "org.xrpl.rpc.v1.PaymentChannelFund"
|
39
|
+
optional :set_regular_key, :message, 27, "org.xrpl.rpc.v1.SetRegularKey"
|
40
|
+
optional :signer_list_set, :message, 28, "org.xrpl.rpc.v1.SignerListSet"
|
41
|
+
optional :trust_set, :message, 29, "org.xrpl.rpc.v1.TrustSet"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
add_message "org.xrpl.rpc.v1.Memo" do
|
45
|
+
optional :memo_data, :message, 1, "org.xrpl.rpc.v1.MemoData"
|
46
|
+
optional :memo_format, :message, 2, "org.xrpl.rpc.v1.MemoFormat"
|
47
|
+
optional :memo_type, :message, 3, "org.xrpl.rpc.v1.MemoType"
|
48
|
+
end
|
49
|
+
add_message "org.xrpl.rpc.v1.Signer" do
|
50
|
+
optional :account, :message, 1, "org.xrpl.rpc.v1.Account"
|
51
|
+
optional :transaction_signature, :message, 2, "org.xrpl.rpc.v1.TransactionSignature"
|
52
|
+
optional :signing_public_key, :message, 3, "org.xrpl.rpc.v1.SigningPublicKey"
|
53
|
+
end
|
54
|
+
add_message "org.xrpl.rpc.v1.AccountSet" do
|
55
|
+
optional :clear_flag, :message, 1, "org.xrpl.rpc.v1.ClearFlag"
|
56
|
+
optional :domain, :message, 2, "org.xrpl.rpc.v1.Domain"
|
57
|
+
optional :email_hash, :message, 3, "org.xrpl.rpc.v1.EmailHash"
|
58
|
+
optional :message_key, :message, 4, "org.xrpl.rpc.v1.MessageKey"
|
59
|
+
optional :set_flag, :message, 5, "org.xrpl.rpc.v1.SetFlag"
|
60
|
+
optional :transfer_rate, :message, 6, "org.xrpl.rpc.v1.TransferRate"
|
61
|
+
optional :tick_size, :message, 7, "org.xrpl.rpc.v1.TickSize"
|
62
|
+
end
|
63
|
+
add_message "org.xrpl.rpc.v1.AccountDelete" do
|
64
|
+
optional :destination, :message, 1, "org.xrpl.rpc.v1.Destination"
|
65
|
+
optional :destination_tag, :message, 2, "org.xrpl.rpc.v1.DestinationTag"
|
66
|
+
end
|
67
|
+
add_message "org.xrpl.rpc.v1.CheckCancel" do
|
68
|
+
optional :check_id, :message, 1, "org.xrpl.rpc.v1.CheckID"
|
69
|
+
end
|
70
|
+
add_message "org.xrpl.rpc.v1.CheckCash" do
|
71
|
+
optional :check_id, :message, 1, "org.xrpl.rpc.v1.CheckID"
|
72
|
+
oneof :amount_oneof do
|
73
|
+
optional :amount, :message, 2, "org.xrpl.rpc.v1.Amount"
|
74
|
+
optional :deliver_min, :message, 3, "org.xrpl.rpc.v1.DeliverMin"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
add_message "org.xrpl.rpc.v1.CheckCreate" do
|
78
|
+
optional :destination, :message, 1, "org.xrpl.rpc.v1.Destination"
|
79
|
+
optional :send_max, :message, 2, "org.xrpl.rpc.v1.SendMax"
|
80
|
+
optional :destination_tag, :message, 3, "org.xrpl.rpc.v1.DestinationTag"
|
81
|
+
optional :expiration, :message, 4, "org.xrpl.rpc.v1.Expiration"
|
82
|
+
optional :invoice_id, :message, 5, "org.xrpl.rpc.v1.InvoiceID"
|
83
|
+
end
|
84
|
+
add_message "org.xrpl.rpc.v1.DepositPreauth" do
|
85
|
+
oneof :authorization_oneof do
|
86
|
+
optional :authorize, :message, 1, "org.xrpl.rpc.v1.Authorize"
|
87
|
+
optional :unauthorize, :message, 2, "org.xrpl.rpc.v1.Unauthorize"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
add_message "org.xrpl.rpc.v1.EscrowCancel" do
|
91
|
+
optional :owner, :message, 1, "org.xrpl.rpc.v1.Owner"
|
92
|
+
optional :offer_sequence, :message, 2, "org.xrpl.rpc.v1.OfferSequence"
|
93
|
+
end
|
94
|
+
add_message "org.xrpl.rpc.v1.EscrowCreate" do
|
95
|
+
optional :amount, :message, 1, "org.xrpl.rpc.v1.Amount"
|
96
|
+
optional :destination, :message, 2, "org.xrpl.rpc.v1.Destination"
|
97
|
+
optional :cancel_after, :message, 3, "org.xrpl.rpc.v1.CancelAfter"
|
98
|
+
optional :finish_after, :message, 4, "org.xrpl.rpc.v1.FinishAfter"
|
99
|
+
optional :condition, :message, 5, "org.xrpl.rpc.v1.Condition"
|
100
|
+
optional :destination_tag, :message, 6, "org.xrpl.rpc.v1.DestinationTag"
|
101
|
+
end
|
102
|
+
add_message "org.xrpl.rpc.v1.EscrowFinish" do
|
103
|
+
optional :owner, :message, 1, "org.xrpl.rpc.v1.Owner"
|
104
|
+
optional :offer_sequence, :message, 2, "org.xrpl.rpc.v1.OfferSequence"
|
105
|
+
optional :condition, :message, 3, "org.xrpl.rpc.v1.Condition"
|
106
|
+
optional :fulfillment, :message, 4, "org.xrpl.rpc.v1.Fulfillment"
|
107
|
+
end
|
108
|
+
add_message "org.xrpl.rpc.v1.OfferCancel" do
|
109
|
+
optional :offer_sequence, :message, 1, "org.xrpl.rpc.v1.OfferSequence"
|
110
|
+
end
|
111
|
+
add_message "org.xrpl.rpc.v1.OfferCreate" do
|
112
|
+
optional :expiration, :message, 1, "org.xrpl.rpc.v1.Expiration"
|
113
|
+
optional :offer_sequence, :message, 2, "org.xrpl.rpc.v1.OfferSequence"
|
114
|
+
optional :taker_gets, :message, 3, "org.xrpl.rpc.v1.TakerGets"
|
115
|
+
optional :taker_pays, :message, 4, "org.xrpl.rpc.v1.TakerPays"
|
116
|
+
end
|
117
|
+
add_message "org.xrpl.rpc.v1.Payment" do
|
118
|
+
optional :amount, :message, 1, "org.xrpl.rpc.v1.Amount"
|
119
|
+
optional :destination, :message, 2, "org.xrpl.rpc.v1.Destination"
|
120
|
+
optional :destination_tag, :message, 3, "org.xrpl.rpc.v1.DestinationTag"
|
121
|
+
optional :invoice_id, :message, 4, "org.xrpl.rpc.v1.InvoiceID"
|
122
|
+
repeated :paths, :message, 5, "org.xrpl.rpc.v1.Payment.Path"
|
123
|
+
optional :send_max, :message, 6, "org.xrpl.rpc.v1.SendMax"
|
124
|
+
optional :deliver_min, :message, 7, "org.xrpl.rpc.v1.DeliverMin"
|
125
|
+
end
|
126
|
+
add_message "org.xrpl.rpc.v1.Payment.PathElement" do
|
127
|
+
optional :account, :message, 1, "org.xrpl.rpc.v1.AccountAddress"
|
128
|
+
optional :currency, :message, 2, "org.xrpl.rpc.v1.Currency"
|
129
|
+
optional :issuer, :message, 3, "org.xrpl.rpc.v1.AccountAddress"
|
130
|
+
end
|
131
|
+
add_message "org.xrpl.rpc.v1.Payment.Path" do
|
132
|
+
repeated :elements, :message, 1, "org.xrpl.rpc.v1.Payment.PathElement"
|
133
|
+
end
|
134
|
+
add_message "org.xrpl.rpc.v1.PaymentChannelClaim" do
|
135
|
+
optional :channel, :message, 1, "org.xrpl.rpc.v1.Channel"
|
136
|
+
optional :balance, :message, 2, "org.xrpl.rpc.v1.Balance"
|
137
|
+
optional :amount, :message, 3, "org.xrpl.rpc.v1.Amount"
|
138
|
+
optional :payment_channel_signature, :message, 4, "org.xrpl.rpc.v1.PaymentChannelSignature"
|
139
|
+
optional :public_key, :message, 5, "org.xrpl.rpc.v1.PublicKey"
|
140
|
+
end
|
141
|
+
add_message "org.xrpl.rpc.v1.PaymentChannelCreate" do
|
142
|
+
optional :amount, :message, 1, "org.xrpl.rpc.v1.Amount"
|
143
|
+
optional :destination, :message, 2, "org.xrpl.rpc.v1.Destination"
|
144
|
+
optional :settle_delay, :message, 3, "org.xrpl.rpc.v1.SettleDelay"
|
145
|
+
optional :public_key, :message, 4, "org.xrpl.rpc.v1.PublicKey"
|
146
|
+
optional :cancel_after, :message, 5, "org.xrpl.rpc.v1.CancelAfter"
|
147
|
+
optional :destination_tag, :message, 6, "org.xrpl.rpc.v1.DestinationTag"
|
148
|
+
end
|
149
|
+
add_message "org.xrpl.rpc.v1.PaymentChannelFund" do
|
150
|
+
optional :channel, :message, 1, "org.xrpl.rpc.v1.Channel"
|
151
|
+
optional :amount, :message, 2, "org.xrpl.rpc.v1.Amount"
|
152
|
+
optional :expiration, :message, 3, "org.xrpl.rpc.v1.Expiration"
|
153
|
+
end
|
154
|
+
add_message "org.xrpl.rpc.v1.SetRegularKey" do
|
155
|
+
optional :regular_key, :message, 1, "org.xrpl.rpc.v1.RegularKey"
|
156
|
+
end
|
157
|
+
add_message "org.xrpl.rpc.v1.SignerListSet" do
|
158
|
+
optional :signer_quorum, :message, 1, "org.xrpl.rpc.v1.SignerQuorum"
|
159
|
+
repeated :signer_entries, :message, 2, "org.xrpl.rpc.v1.SignerEntry"
|
160
|
+
end
|
161
|
+
add_message "org.xrpl.rpc.v1.TrustSet" do
|
162
|
+
optional :limit_amount, :message, 1, "org.xrpl.rpc.v1.LimitAmount"
|
163
|
+
optional :quality_in, :message, 2, "org.xrpl.rpc.v1.QualityIn"
|
164
|
+
optional :quality_out, :message, 3, "org.xrpl.rpc.v1.QualityOut"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
module Org
|
170
|
+
module Xrpl
|
171
|
+
module Rpc
|
172
|
+
module V1
|
173
|
+
Transaction = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.Transaction").msgclass
|
174
|
+
Memo = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.Memo").msgclass
|
175
|
+
Signer = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.Signer").msgclass
|
176
|
+
AccountSet = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.AccountSet").msgclass
|
177
|
+
AccountDelete = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.AccountDelete").msgclass
|
178
|
+
CheckCancel = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.CheckCancel").msgclass
|
179
|
+
CheckCash = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.CheckCash").msgclass
|
180
|
+
CheckCreate = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.CheckCreate").msgclass
|
181
|
+
DepositPreauth = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.DepositPreauth").msgclass
|
182
|
+
EscrowCancel = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.EscrowCancel").msgclass
|
183
|
+
EscrowCreate = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.EscrowCreate").msgclass
|
184
|
+
EscrowFinish = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.EscrowFinish").msgclass
|
185
|
+
OfferCancel = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.OfferCancel").msgclass
|
186
|
+
OfferCreate = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.OfferCreate").msgclass
|
187
|
+
Payment = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.Payment").msgclass
|
188
|
+
Payment::PathElement = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.Payment.PathElement").msgclass
|
189
|
+
Payment::Path = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.Payment.Path").msgclass
|
190
|
+
PaymentChannelClaim = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.PaymentChannelClaim").msgclass
|
191
|
+
PaymentChannelCreate = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.PaymentChannelCreate").msgclass
|
192
|
+
PaymentChannelFund = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.PaymentChannelFund").msgclass
|
193
|
+
SetRegularKey = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.SetRegularKey").msgclass
|
194
|
+
SignerListSet = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.SignerListSet").msgclass
|
195
|
+
TrustSet = Google::Protobuf::DescriptorPool.generated_pool.lookup("org.xrpl.rpc.v1.TrustSet").msgclass
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: org/xrpl/rpc/v1/xrp_ledger.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'org/xrpl/rpc/v1/get_account_info_pb'
|
7
|
+
require 'org/xrpl/rpc/v1/get_fee_pb'
|
8
|
+
require 'org/xrpl/rpc/v1/submit_pb'
|
9
|
+
require 'org/xrpl/rpc/v1/get_transaction_pb'
|
10
|
+
require 'org/xrpl/rpc/v1/get_account_transaction_history_pb'
|
11
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
12
|
+
add_file("org/xrpl/rpc/v1/xrp_ledger.proto", :syntax => :proto3) do
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Org
|
17
|
+
module Xrpl
|
18
|
+
module Rpc
|
19
|
+
module V1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: org/xrpl/rpc/v1/xrp_ledger.proto for package 'org.xrpl.rpc.v1'
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require 'org/xrpl/rpc/v1/xrp_ledger_pb'
|
6
|
+
|
7
|
+
module Org
|
8
|
+
module Xrpl
|
9
|
+
module Rpc
|
10
|
+
module V1
|
11
|
+
module XRPLedgerAPIService
|
12
|
+
# RPCs available to interact with the XRP Ledger.
|
13
|
+
class Service
|
14
|
+
|
15
|
+
include GRPC::GenericService
|
16
|
+
|
17
|
+
self.marshal_class_method = :encode
|
18
|
+
self.unmarshal_class_method = :decode
|
19
|
+
self.service_name = 'org.xrpl.rpc.v1.XRPLedgerAPIService'
|
20
|
+
|
21
|
+
# Get account info for an account on the XRP Ledger.
|
22
|
+
rpc :GetAccountInfo, GetAccountInfoRequest, GetAccountInfoResponse
|
23
|
+
# Get the fee for a transaction on the XRP Ledger.
|
24
|
+
rpc :GetFee, GetFeeRequest, GetFeeResponse
|
25
|
+
# Submit a signed transaction to the XRP Ledger.
|
26
|
+
rpc :SubmitTransaction, SubmitTransactionRequest, SubmitTransactionResponse
|
27
|
+
# Get the status of a transaction
|
28
|
+
rpc :GetTransaction, GetTransactionRequest, GetTransactionResponse
|
29
|
+
rpc :GetAccountTransactionHistory, GetAccountTransactionHistoryRequest, GetAccountTransactionHistoryResponse
|
30
|
+
end
|
31
|
+
|
32
|
+
Stub = Service.rpc_stub_class
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/xpring.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "xpring/version"
|
4
|
+
require "xpring/wallet"
|
5
|
+
require "xpring/util"
|
6
|
+
require "xpring/client"
|
7
|
+
require "xpring/error"
|
8
|
+
|
9
|
+
# Entrypoint of library
|
10
|
+
module Xpring
|
11
|
+
@debug = false
|
12
|
+
|
13
|
+
# @return [true, false]
|
14
|
+
def self.debug?
|
15
|
+
@debug
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [true, false]
|
19
|
+
def self.toggle_debug!
|
20
|
+
@debug = !@debug
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param value [#to_s]
|
24
|
+
# @return [nil]
|
25
|
+
def self.debug_log(value)
|
26
|
+
puts value if debug?
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "grpc"
|
4
|
+
require "xpring/util"
|
5
|
+
require "xpring/error"
|
6
|
+
require "xpring/signer"
|
7
|
+
require "org/xrpl/rpc/v1/get_account_info_pb"
|
8
|
+
require "org/xrpl/rpc/v1/get_transaction_pb"
|
9
|
+
require "org/xrpl/rpc/v1/account_pb"
|
10
|
+
require "org/xrpl/rpc/v1/submit_pb"
|
11
|
+
require "org/xrpl/rpc/v1/xrp_ledger_services_pb"
|
12
|
+
require "org/xrpl/rpc/v1/get_fee_pb"
|
13
|
+
|
14
|
+
module Xpring
|
15
|
+
# Make GRPC network calls to XRP ledger
|
16
|
+
class Client
|
17
|
+
MAX_LEDGER_VERSION_OFFSET = 10
|
18
|
+
X_ADDRESS_REQUIRED_MSG = "Please use the X-Address format. See: https://xrpaddress.info"
|
19
|
+
private_constant :MAX_LEDGER_VERSION_OFFSET, :X_ADDRESS_REQUIRED_MSG
|
20
|
+
|
21
|
+
attr_reader :grpc_url, :credentials
|
22
|
+
|
23
|
+
# @param grpc_url [#to_s]
|
24
|
+
# @param credentials [GRPC::Core::ChannelCredentials,
|
25
|
+
# :this_channel_is_insecure]
|
26
|
+
def initialize(grpc_url, credentials: :this_channel_is_insecure)
|
27
|
+
@grpc_url = grpc_url.to_s
|
28
|
+
@credentials = credentials
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param address [#to_s] classic address
|
32
|
+
# @return [Integer, nil]
|
33
|
+
def balance_of(address)
|
34
|
+
account_data(address.to_s)&.account_data
|
35
|
+
&.balance&.value&.xrp_amount&.drops
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param transaction [#to_s]
|
39
|
+
# @return [Symbol, nil]
|
40
|
+
def status_of(transaction)
|
41
|
+
transaction_data(transaction.to_s)&.meta
|
42
|
+
&.transaction_result&.result_type
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param amount [#to_s]
|
46
|
+
# @param to [#to_s]
|
47
|
+
# @param from [Xpring::Wallet]
|
48
|
+
# @raise [Xpring::Error]
|
49
|
+
# @return [Org::Xrpl::Rpc::V1::SubmitTransactionResponse]
|
50
|
+
def send_xrp(amount:, to:, from:)
|
51
|
+
to = to.to_s
|
52
|
+
|
53
|
+
raise Error.new(X_ADDRESS_REQUIRED_MSG) unless Util.valid_x_address?(to)
|
54
|
+
|
55
|
+
classic_from_address = Util.decode(from.address)[:address]
|
56
|
+
raise Error.new(X_ADDRESS_REQUIRED_MSG) unless classic_from_address
|
57
|
+
|
58
|
+
classic_to_address = Util.decode(to)[:address]
|
59
|
+
raise Error.new(X_ADDRESS_REQUIRED_MSG) unless classic_to_address
|
60
|
+
|
61
|
+
account_data = account_data(classic_from_address)
|
62
|
+
raise Error.new(X_ADDRESS_REQUIRED_MSG) if account_data.nil?
|
63
|
+
|
64
|
+
transaction_hash = {
|
65
|
+
Account: classic_from_address,
|
66
|
+
Fee: minimum_fee.to_s, # ripple-binary-codec requires string
|
67
|
+
LastLedgerSequence: next_sequence_for_transaction,
|
68
|
+
Sequence: account_data.account_data.sequence.value,
|
69
|
+
SigningPubKey: from.public_key,
|
70
|
+
Amount: amount.to_s, # ripple-binary-codec requires string
|
71
|
+
Destination: classic_to_address,
|
72
|
+
TransactionType: "Payment",
|
73
|
+
}
|
74
|
+
|
75
|
+
client.submit_transaction(Org::Xrpl::Rpc::V1::SubmitTransactionRequest.new(
|
76
|
+
signed_transaction: Signer.sign(
|
77
|
+
transaction_hash: transaction_hash,
|
78
|
+
from_wallet: from,
|
79
|
+
),
|
80
|
+
))
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def client
|
86
|
+
@client ||= Org::Xrpl::Rpc::V1::XRPLedgerAPIService::Stub.new(
|
87
|
+
grpc_url,
|
88
|
+
credentials,
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def fee_response
|
93
|
+
client.get_fee(Org::Xrpl::Rpc::V1::GetFeeRequest.new)
|
94
|
+
end
|
95
|
+
|
96
|
+
def minimum_fee
|
97
|
+
fee_response.fee.minimum_fee.drops
|
98
|
+
end
|
99
|
+
|
100
|
+
def account_data(address)
|
101
|
+
client.get_account_info(Org::Xrpl::Rpc::V1::GetAccountInfoRequest.new(
|
102
|
+
account: Org::Xrpl::Rpc::V1::AccountAddress.new(
|
103
|
+
address: address,
|
104
|
+
),
|
105
|
+
))
|
106
|
+
rescue GRPC::NotFound
|
107
|
+
end
|
108
|
+
|
109
|
+
def transaction_data(transaction)
|
110
|
+
client.get_transaction(Org::Xrpl::Rpc::V1::GetTransactionRequest.new(
|
111
|
+
hash: Util.byte_string_from_string(transaction),
|
112
|
+
))
|
113
|
+
rescue GRPC::NotFound
|
114
|
+
end
|
115
|
+
|
116
|
+
def next_sequence_for_transaction
|
117
|
+
fee_response.ledger_current_index + MAX_LEDGER_VERSION_OFFSET
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|