Skip to content

Commit 7391326

Browse files
Merge pull request #242 from ElrondNetwork/v10-into-main
Merge v10 into main
2 parents 62aad3b + c4a7906 commit 7391326

File tree

6 files changed

+90
-32
lines changed

6 files changed

+90
-32
lines changed

.github/workflows/erdjs-publish-alpha-beta.yml renamed to .github/workflows/erdjs-publish-not-main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish erdjs (alpha / beta)
1+
name: Publish erdjs (not main)
22

33
on:
44
workflow_dispatch:
@@ -9,6 +9,7 @@ on:
99
options:
1010
- alpha
1111
- beta
12+
- previous
1213

1314
permissions:
1415
contents: write

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ All notable changes will be documented in this file.
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
## 11.1.1
8+
- [Fix `CompositeValue.valueOf()`](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/241)
9+
710
## 11.1.0
8-
- [Add builder for relayed v1 transactions](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/235)
11+
- [Add builder for relayed v1 transactions](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/235)
912

1013
## 11.0.1
1114
- [Fix construction of AbiRegistry](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/234)

package-lock.json

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elrondnetwork/erdjs",
3-
"version": "11.1.0",
3+
"version": "11.1.1",
44
"description": "Smart Contracts interaction framework",
55
"main": "out/index.js",
66
"types": "out/index.d.js",
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { assert } from "chai";
2+
import { ArgSerializer } from "../argSerializer";
3+
import { BytesType, BytesValue } from "./bytes";
4+
import { CompositeType, CompositeValue } from "./composite";
5+
import { EndpointParameterDefinition } from "./endpoint";
6+
import { U32Type, U32Value } from "./numerical";
7+
8+
9+
describe("test composite", () => {
10+
const serializer = new ArgSerializer();
11+
12+
it("should get valueOf()", () => {
13+
const compositeType = new CompositeType(new U32Type(), new BytesType());
14+
const compositeValue = new CompositeValue(compositeType, [new U32Value(7), BytesValue.fromUTF8("hello")]);
15+
16+
const values = compositeValue.valueOf();
17+
assert.lengthOf(values, 2);
18+
assert.equal(7, values[0]);
19+
assert.equal("hello", values[1]);
20+
});
21+
22+
it("should get valueOf() upon decoding", () => {
23+
const compositeType = new CompositeType(new U32Type(), new BytesType());
24+
const endpointDefinition = new EndpointParameterDefinition("", "", compositeType)
25+
26+
const [compositeValue] = serializer.stringToValues("2a@abba", [endpointDefinition]);
27+
const values = compositeValue.valueOf();
28+
assert.lengthOf(values, 2);
29+
assert.equal(42, values[0]);
30+
assert.deepEqual(Buffer.from([0xab, 0xba]), values[1]);
31+
});
32+
33+
it("should get valueOf(), when items are missing", () => {
34+
const compositeType = new CompositeType(new U32Type(), new BytesType());
35+
const items: any = [null, null];
36+
const compositeValue = new CompositeValue(compositeType, items);
37+
38+
const values = compositeValue.valueOf();
39+
assert.lengthOf(values, 2);
40+
assert.isUndefined(values[0]);
41+
assert.isUndefined(values[1]);
42+
});
43+
44+
it("should get valueOf() upon decoding, when items are missing", () => {
45+
const compositeType = new CompositeType(new U32Type(), new BytesType());
46+
const endpointDefinition = new EndpointParameterDefinition("", "", compositeType)
47+
48+
const [compositeValue] = serializer.stringToValues("", [endpointDefinition]);
49+
const values = compositeValue.valueOf();
50+
assert.lengthOf(values, 2);
51+
assert.equal(0, values[0]);
52+
assert.isUndefined(values[1]);
53+
});
54+
});

src/smartcontracts/typesystem/composite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class CompositeValue extends TypedValue {
4242
}
4343

4444
valueOf(): any[] {
45-
return this.items.map(item => item.valueOf());
45+
return this.items.map(item => item?.valueOf());
4646
}
4747

4848
equals(other: CompositeValue): boolean {

0 commit comments

Comments
 (0)