Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit 7375dec

Browse files
authored
Merge pull request #34 from tomerweller/master
further bumpseq support
2 parents fd162d8 + 28a8c0f commit 7375dec

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/.vscode
1515
mkmf.log
1616
.DS_Store
17+
.idea
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This code was automatically generated using xdrgen
2+
# DO NOT EDIT or your changes may be overwritten
3+
4+
require 'xdr'
5+
6+
# === xdr source ============================================================
7+
#
8+
# struct BumpSequenceOp
9+
# {
10+
# SequenceNumber bumpTo;
11+
# };
12+
#
13+
# ===========================================================================
14+
module Stellar
15+
class BumpSequenceOp < XDR::Struct
16+
attribute :bump_to, SequenceNumber
17+
end
18+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This code was automatically generated using xdrgen
2+
# DO NOT EDIT or your changes may be overwritten
3+
4+
require 'xdr'
5+
6+
# === xdr source ============================================================
7+
#
8+
# union BumpSequenceResult switch (BumpSequenceResultCode code)
9+
# {
10+
# case BUMP_SEQUENCE_SUCCESS:
11+
# void;
12+
# default:
13+
# void;
14+
# };
15+
#
16+
# ===========================================================================
17+
module Stellar
18+
class BumpSequenceResult < XDR::Union
19+
switch_on BumpSequenceResultCode, :code
20+
21+
switch :bump_sequence_success
22+
switch :default
23+
24+
end
25+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This code was automatically generated using xdrgen
2+
# DO NOT EDIT or your changes may be overwritten
3+
4+
require 'xdr'
5+
6+
# === xdr source ============================================================
7+
#
8+
# enum BumpSequenceResultCode
9+
# {
10+
# // codes considered as "success" for the operation
11+
# BUMP_SEQUENCE_SUCCESS = 0,
12+
# // codes considered as "failure" for the operation
13+
# BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds
14+
# };
15+
#
16+
# ===========================================================================
17+
module Stellar
18+
class BumpSequenceResultCode < XDR::Enum
19+
member :bump_sequence_success, 0
20+
member :bump_sequence_bad_seq, -1
21+
22+
seal
23+
end
24+
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This code was automatically generated using xdrgen
2+
# DO NOT EDIT or your changes may be overwritten
3+
4+
require 'xdr'
5+
6+
# === xdr source ============================================================
7+
#
8+
# struct TransactionMetaV1
9+
# {
10+
# LedgerEntryChanges txChanges; // tx level changes if any
11+
# OperationMeta operations<>; // meta for each operation
12+
# };
13+
#
14+
# ===========================================================================
15+
module Stellar
16+
class TransactionMetaV1 < XDR::Struct
17+
attribute :tx_changes, LedgerEntryChanges
18+
attribute :operations, XDR::VarArray[OperationMeta]
19+
end
20+
end

lib/stellar/operation.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,20 @@ def self.manage_data(attributes={})
308308
}))
309309
end
310310

311+
def self.bump_sequence(attributes={})
312+
op = BumpSequenceOp.new()
313+
314+
bump_to = attributes[:bump_to]
315+
316+
raise ArgumentError, ":bump_to too big" unless bump_to <= MAX_INT64
317+
318+
op.bump_to = bump_to
319+
320+
return make(attributes.merge({
321+
body:[:bump_sequence, op]
322+
}))
323+
end
324+
311325
private
312326
def self.extract_amount(a)
313327
amount = interpret_amount(a.last)

lib/stellar/transaction.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def self.manage_data(attributes={})
6767
make :manage_data, attributes
6868
end
6969

70+
#
71+
# @see Stellar::Operation.manage_data
72+
def self.bump_sequence(attributes={})
73+
make :bump_sequence, attributes
74+
end
75+
7076
#
7177
# Helper method to create a transaction with a single
7278
# operation of the provided type. See class methods

0 commit comments

Comments
 (0)