Skip to content

Commit e65ee85

Browse files
Remove "required" for currency precision to allow zero precision.
1 parent 419568a commit e65ee85

File tree

8 files changed

+41
-36
lines changed

8 files changed

+41
-36
lines changed

cmd/tokenized/cmd/cmd_decode.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ var cmdDecode = &cobra.Command{
2020
return errors.New("Wrong argument count : requires 1")
2121
}
2222

23+
if len(args[0]) > 2 && args[0][0] == '0' && args[0][1] == 'x' {
24+
b, hexErr := hex.DecodeString(args[0][2:])
25+
if hexErr == nil {
26+
if err := print.PrintBytes(b); err != nil {
27+
return errors.Wrap(err, "decode")
28+
}
29+
30+
return nil
31+
}
32+
}
33+
2334
b, hexErr := hex.DecodeString(args[0])
2435
if hexErr == nil {
2536
if err := print.PrintBytes(b); err != nil {

dist/golang/instruments/validate.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,6 @@ func (a *CurrencyValueField) Validate() error {
530530
if a.Precision > uint32(max1ByteInteger) {
531531
return fmt.Errorf("Precision over max value : %d > %d", a.Precision, max1ByteInteger)
532532
}
533-
if a.Precision == 0 {
534-
return fmt.Errorf("Precision required")
535-
}
536533

537534
return nil
538535
}
@@ -573,9 +570,6 @@ func (a *FixedCurrencyValueField) Validate() error {
573570
if a.Precision > uint32(max1ByteInteger) {
574571
return fmt.Errorf("Precision over max value : %d > %d", a.Precision, max1ByteInteger)
575572
}
576-
if a.Precision == 0 {
577-
return fmt.Errorf("Precision required")
578-
}
579573

580574
return nil
581575
}

dist/json/instruments.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@
7373
"type": "CurrencyType"
7474
},
7575
{
76-
"description": "Required field to specify the decimal precision of the value. It will normally be the \"precision\" value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount \"$1.00\". In this scenario 100 tokens are worth $1.\n",
76+
"description": "Specify the decimal precision of the value. It will normally be the \"precision\" value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount \"$1.00\". In this scenario 100 tokens are worth $1. Zero is assumed if no value is specified.\n",
7777
"example": 2,
7878
"label": "Precision",
7979
"name": "Precision",
80-
"required": true,
8180
"size": 1,
8281
"type": "uint"
8382
}
@@ -109,11 +108,10 @@
109108
"type": "CurrencyType"
110109
},
111110
{
112-
"description": "Required field to specify the decimal precision of the value. It will normally be the \"precision\" value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount \"$1.00\". In this scenario 100 tokens are worth $1.\n",
111+
"description": "Specify the decimal precision of the value. It will normally be the \"precision\" value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount \"$1.00\". In this scenario 100 tokens are worth $1. Zero is assumed if no value is specified.\n",
113112
"example": 2,
114113
"label": "Precision",
115114
"name": "Precision",
116-
"required": true,
117115
"size": 1,
118116
"type": "uint"
119117
}

dist/markdown/protocol-instruments.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,9 @@ A value specified in terms of a currency.
12341234
uint(1)
12351235
</td>
12361236
<td>
1237-
Required field to specify the decimal precision of the value. It will normally be the &#34;precision&#34; value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount &#34;$1.00&#34;. In this scenario 100 tokens are worth $1.
1237+
Specify the decimal precision of the value. It will normally be the &#34;precision&#34; value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount &#34;$1.00&#34;. In this scenario 100 tokens are worth $1. Zero is assumed if no value is specified.
12381238

1239-
This field is always required. Example: 2
1239+
Example: 2
12401240
</td>
12411241
</tr>
12421242

@@ -1286,9 +1286,9 @@ A fixed value specified in terms of a currency. The &#34;Value&#34; must be 1. T
12861286
uint(1)
12871287
</td>
12881288
<td>
1289-
Required field to specify the decimal precision of the value. It will normally be the &#34;precision&#34; value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount &#34;$1.00&#34;. In this scenario 100 tokens are worth $1.
1289+
Specify the decimal precision of the value. It will normally be the &#34;precision&#34; value associated with the Currency. It is the number of decimal places between the number of tokens and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token would only be worth a penny. So the precision should be 2 for the two decimal places in a dollar amount &#34;$1.00&#34;. In this scenario 100 tokens are worth $1. Zero is assumed if no value is specified.
12901290

1291-
This field is always required. Example: 2
1291+
Example: 2
12921292
</td>
12931293
</tr>
12941294

dist/swagger/instruments/CurrencyValueField.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ properties:
1414
example: "AUD"
1515
Precision:
1616
description: >
17-
Required field to specify the decimal precision of the value. It will normally be the
18-
"precision" value associated with the Currency. It is the number of decimal places between the
19-
number of tokens and the common unit of measure. For example, in AUD, the common unit is the
20-
dollar, but a token would only be worth a penny. So the precision should be 2 for the two
21-
decimal places in a dollar amount "$1.00". In this scenario 100 tokens are worth $1.
17+
Specify the decimal precision of the value. It will normally be the "precision" value
18+
associated with the Currency. It is the number of decimal places between the number of tokens
19+
and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token
20+
would only be worth a penny. So the precision should be 2 for the two decimal places in a
21+
dollar amount "$1.00". In this scenario 100 tokens are worth $1. Zero is assumed if no value is
22+
specified.
2223
type: number
2324
example: 2
2425

dist/swagger/instruments/FixedCurrencyValueField.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ properties:
1616
example: "AUD"
1717
Precision:
1818
description: >
19-
Required field to specify the decimal precision of the value. It will normally be the
20-
"precision" value associated with the Currency. It is the number of decimal places between the
21-
number of tokens and the common unit of measure. For example, in AUD, the common unit is the
22-
dollar, but a token would only be worth a penny. So the precision should be 2 for the two
23-
decimal places in a dollar amount "$1.00". In this scenario 100 tokens are worth $1.
19+
Specify the decimal precision of the value. It will normally be the "precision" value
20+
associated with the Currency. It is the number of decimal places between the number of tokens
21+
and the common unit of measure. For example, in AUD, the common unit is the dollar, but a token
22+
would only be worth a penny. So the precision should be 2 for the two decimal places in a
23+
dollar amount "$1.00". In this scenario 100 tokens are worth $1. Zero is assumed if no value is
24+
specified.
2425
type: number
2526
example: 2
2627

src/instruments/develop/types/CurrencyValue.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ fields:
2626
- name: Precision
2727
label: Precision
2828
description: >
29-
Required field to specify the decimal precision of the value. It will normally be the
30-
"precision" value associated with the Currency. It is the number of decimal places between
31-
the number of tokens and the common unit of measure. For example, in AUD, the common unit is
32-
the dollar, but a token would only be worth a penny. So the precision should be 2 for the
33-
two decimal places in a dollar amount "$1.00". In this scenario 100 tokens are worth $1.
29+
Specify the decimal precision of the value. It will normally be the "precision" value
30+
associated with the Currency. It is the number of decimal places between the number of
31+
tokens and the common unit of measure. For example, in AUD, the common unit is the dollar,
32+
but a token would only be worth a penny. So the precision should be 2 for the two decimal
33+
places in a dollar amount "$1.00". In this scenario 100 tokens are worth $1. Zero is assumed
34+
if no value is specified.
3435
type: uint
35-
required: true
3636
size: 1
3737
example: 2

src/instruments/develop/types/FixedCurrencyValue.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ fields:
3131
- name: Precision
3232
label: Precision
3333
description: >
34-
Required field to specify the decimal precision of the value. It will normally be the
35-
"precision" value associated with the Currency. It is the number of decimal places between
36-
the number of tokens and the common unit of measure. For example, in AUD, the common unit is
37-
the dollar, but a token would only be worth a penny. So the precision should be 2 for the
38-
two decimal places in a dollar amount "$1.00". In this scenario 100 tokens are worth $1.
34+
Specify the decimal precision of the value. It will normally be the "precision" value
35+
associated with the Currency. It is the number of decimal places between the number of
36+
tokens and the common unit of measure. For example, in AUD, the common unit is the dollar,
37+
but a token would only be worth a penny. So the precision should be 2 for the two decimal
38+
places in a dollar amount "$1.00". In this scenario 100 tokens are worth $1. Zero is assumed
39+
if no value is specified.
3940
type: uint
40-
required: true
4141
size: 1
4242
example: 2

0 commit comments

Comments
 (0)