Skip to content

Commit e2d2d5e

Browse files
1658 bnc part 2 (#1788)
* fix: fix BNC... * fix: fix BNC... * fix: fix BNC... * fix: fix BNC... * fix: fix BNC... * fix: fix BNC... * fix: en_7 recommendations... (#1749) * fix: fr9 recommendations * fix: en_1 recommendations * fix: en_1 recommendations * fix: en_2 recommendations... * fix: en_2 recommendations... * fix: en_7 recommendations... * fix: en_7 recommendations... * fix: n_7 recommandations * fix: n_7 recommandations * Merge branch 'main' into 1656-fr9 * Merge branch '1661-en_2' into 1662-en_7 * fix: EN_7 * fix: EN_7 * fix: EN_7 --------- Co-authored-by: Fabio Rigamonti <73019897+fabiorigam@users.noreply.github.com> (cherry picked from commit f52a556) * fix: BNC (network) * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * fix: BNC 2 network * Update packages/rpc-proxy/src/utils/config-validator/config-validator.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Luca Nicola Debiasi <63785793+lucanicoladebiasi@users.noreply.github.com> * Update packages/rpc-proxy/src/utils/config-validator/config-validator.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Luca Nicola Debiasi <63785793+lucanicoladebiasi@users.noreply.github.com> * fix: BNC 2 network * fix: `BNC` part 2 - network refactor * fix: `BNC` part 2 - network refactor * fix: `BNC` part 2 - network refactor * fix: `BNC` part 2 - network refactor * fix: `BNC` part 2 - openssl fix * fix: `BNC` part 2 - openssl fix * fix: `BNC` part 2 - rpc-proxy README.md amended --------- Signed-off-by: Luca Nicola Debiasi <63785793+lucanicoladebiasi@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent f52a556 commit e2d2d5e

File tree

76 files changed

+407
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+407
-413
lines changed

.github/workflows/rpc-proxy-docker.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
- name: Set up QEMU
2020
if: ${{ github.event_name != 'pull_request' }}
2121
uses: docker/setup-qemu-action@v3
22-
22+
2323
- name: Set up Docker Buildx
2424
if: ${{ github.event_name != 'pull_request' }}
2525
uses: docker/setup-buildx-action@v3
26-
26+
2727
- name: Login to Docker Hub
2828
if: ${{ github.event_name != 'pull_request' }}
2929
uses: docker/login-action@v3
@@ -36,7 +36,7 @@ jobs:
3636
uses: docker/metadata-action@v5
3737
with:
3838
images: vechain/sdk-rpc-proxy
39-
39+
4040
- name: Build and export to Docker
4141
uses: docker/build-push-action@v6
4242
with:
@@ -48,8 +48,10 @@ jobs:
4848

4949
- name: Create .trivyignore file
5050
# "cross-spawn" is resolved as version 7.0.5 but Trivy keeps showing the error
51-
run: echo "CVE-2024-21538" > .trivyignore
52-
51+
run: |
52+
echo "CVE-2024-21538" > .trivyignore
53+
echo "CVE-2024-13176" >> .trivyignore
54+
5355
- name: Run Trivy Scan
5456
uses: aquasecurity/trivy-action@master
5557
with:
@@ -64,7 +66,7 @@ jobs:
6466
env:
6567
# See https://github.com/aquasecurity/trivy/discussions/7538
6668
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
67-
69+
6870
- name: Build and push
6971
if: ${{ github.event_name != 'pull_request' }}
7072
uses: docker/build-push-action@v6

apps/sdk-cloudflare-integration/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
};
3636

3737
// Create private key
38-
const privateKey = await Secp256k1.generatePrivateKey();
38+
const privateKey = Secp256k1.generatePrivateKey();
3939

4040
// 4 - Sign transaction
4141
const signedTransaction = Transaction.of(body).sign(privateKey);

apps/sdk-hardhat-integration/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The `hardhat.config.js` is the main configuration file. By specifying the desire
1919
Note that:
2020

2121
- The network name should contain `vechain`, otherwise, it may result in an error.
22-
- In the network configuration, two additional fields can be added: `delegator` and `useDebug`. These fields allow for more customization and control over the network settings, catering to specific project requirements and preferences.
22+
- In the network configuration, two additional fields can be added: `gasPayer` and `useDebug`. These fields allow for more customization and control over the network settings, catering to specific project requirements and preferences.
2323
- **Debug Mode**: The `debug` field enables or disables debug mode.
24-
- **Delegator**: The `delegator` field allows you to delegate the transaction to a delegator. It supports two optional parameters: - **Delegator**: The `delegator` field allows you to delegate the transaction to a delegator. It supports two optional parameters: `delegatorPrivateKey` and `delegatorUrl`.
24+
- **Delegator**: The `gasPayer` field allows you to delegate the transaction to a gasPayer. It supports two optional parameters: - **Delegator**: The `gasPayer` field allows you to delegate the transaction to a gasPayer. It supports two optional parameters: `delegatorPrivateKey` and `delegatorUrl`.
2525
- When configuring your Solidity compiler settings in hardhat.config.js, it's recommended to set the evmVersion to "Paris" for projects targeting the latest EVM functionalities. This setting ensures that the compiled bytecode is optimized for the most recent features and gas cost adjustments associated with the Paris EVM version. Using an EVM version other than "Paris" could potentially lead to issues with unsupported opcodes, especially if your contracts rely on newer EVM features introduced in or after the Paris update.
2626

27-
This flexibility in the configuration file allows developers to tailor their development experience and adapt it to the requirements of their projects, ensuring a smooth and efficient development process.
27+
This flexibility in the configuration file allows developers to tailor their development experience and adapt it to the requirements of their projects, ensuring a smooth and efficient development process.

apps/sdk-hardhat-integration/hardhat.config.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { type HttpNetworkConfig } from 'hardhat/types';
1212
*
1313
* They have custom parameters:
1414
* - debug: whether to enable debug mode
15-
* - delegator: the delegator to use
15+
* - gasPayer: the gasPayer to use
1616
* - enableDelegation: whether to enable fee delegation
1717
*/
1818
const config: HardhatUserConfig = {
@@ -42,7 +42,7 @@ const config: HardhatUserConfig = {
4242
'7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158'
4343
],
4444
debug: false,
45-
delegator: undefined,
45+
gasPayer: undefined,
4646
gas: 'auto',
4747
gasPrice: 'auto',
4848
gasMultiplier: 1,
@@ -65,7 +65,7 @@ const config: HardhatUserConfig = {
6565
passphrase: 'vechainthor'
6666
},
6767
debug: true,
68-
delegator: undefined,
68+
gasPayer: undefined,
6969
gas: 'auto',
7070
gasPrice: 'auto',
7171
gasMultiplier: 1,
@@ -74,7 +74,7 @@ const config: HardhatUserConfig = {
7474
} satisfies HttpNetworkConfig,
7575

7676
/**
77-
* Testnet configuration - with delegator url
77+
* Testnet configuration - with gasPayer url
7878
*/
7979
vechain_testnet_delegator_url: {
8080
// Testnet
@@ -88,7 +88,7 @@ const config: HardhatUserConfig = {
8888
passphrase: 'vechainthor'
8989
},
9090
debug: true,
91-
delegator: {
91+
gasPayer: {
9292
delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269'
9393
},
9494
enableDelegation: true,
@@ -100,7 +100,7 @@ const config: HardhatUserConfig = {
100100
} satisfies HttpNetworkConfig,
101101

102102
/**
103-
* Testnet configuration - with delegator private key
103+
* Testnet configuration - with gasPayer private key
104104
*/
105105
vechain_testnet_delegator_private_key: {
106106
// Testnet
@@ -114,7 +114,7 @@ const config: HardhatUserConfig = {
114114
passphrase: 'vechainthor'
115115
},
116116
debug: true,
117-
delegator: {
117+
gasPayer: {
118118
delegatorPrivateKey:
119119
'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5'
120120
},
@@ -137,7 +137,7 @@ const config: HardhatUserConfig = {
137137
],
138138
debug: false,
139139
enableDelegation: false,
140-
delegator: undefined,
140+
gasPayer: undefined,
141141
gas: 'auto',
142142
gasPrice: 'auto',
143143
gasMultiplier: 1,

docker-compose.rpc-proxy.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ services:
6565

6666
# Default configuration for the RPC proxy service
6767
rpc-proxy:
68-
build:
68+
build:
6969
context: .
7070
dockerfile: docker/rpc-proxy/Dockerfile
7171
container_name: rpc-proxy
@@ -80,7 +80,7 @@ services:
8080

8181
# 1. Example of a custom configuration file for the RPC proxy service
8282
rpc-proxy-custom-config-file:
83-
build:
83+
build:
8484
context: .
8585
dockerfile: docker/rpc-proxy/Dockerfile
8686
environment:
@@ -95,7 +95,7 @@ services:
9595

9696
# 2. Example of a custom parameters for the RPC proxy service
9797
rpc-proxy-custom-parameters:
98-
build:
98+
build:
9999
context: .
100100
dockerfile: docker/rpc-proxy/Dockerfile
101101
environment:
@@ -110,7 +110,7 @@ services:
110110

111111
# 3. Example of a custom accounts for the RPC proxy service
112112
rpc-proxy-custom-accounts:
113-
build:
113+
build:
114114
context: .
115115
dockerfile: docker/rpc-proxy/Dockerfile
116116
environment:
@@ -125,7 +125,7 @@ services:
125125

126126
# 3. Example of a custom mnemonic for the RPC proxy service
127127
rpc-proxy-custom-mnemonic:
128-
build:
128+
build:
129129
context: .
130130
dockerfile: docker/rpc-proxy/Dockerfile
131131
environment:
@@ -142,7 +142,7 @@ services:
142142

143143
# 4. Example of a custom delegation by private key for the RPC proxy service
144144
rpc-proxy-with-delegation-by-private-key:
145-
build:
145+
build:
146146
context: .
147147
dockerfile: docker/rpc-proxy/Dockerfile
148148
environment:
@@ -161,7 +161,7 @@ services:
161161

162162
# 5. Example of a custom delegation by url for the RPC proxy service
163163
rpc-proxy-with-delegation-by-url:
164-
build:
164+
build:
165165
context: .
166166
dockerfile: docker/rpc-proxy/Dockerfile
167167
environment:

docker/rpc-proxy/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ COPY --from=builder /app/yarn.lock /app/yarn.lock
4747
WORKDIR /app
4848
RUN yarn workspace @vechain/sdk-rpc-proxy install --production --frozen-lockfile --ignore-scripts --prefer-offline \
4949
&& yarn cache clean \
50-
&& adduser -D rpc-proxy-user
50+
&& adduser -D rpc-proxy-user
5151
# Create a new user to run the app so we do not use root
5252
USER rpc-proxy-user
5353

5454
# Tell we are running with Docker
5555
ENV RUNNING_WITH_DOCKER=true
5656

5757
# Set the default command to use node to run the app
58-
CMD ["node", "packages/rpc-proxy/dist/index.js"]
58+
CMD ["node", "packages/rpc-proxy/dist/index.js"]

docs/contracts.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ const thorSoloClient = ThorClient.at(THOR_SOLO_URL);
209209
const provider = new VeChainProvider(
210210
thorSoloClient,
211211
new ProviderInternalBaseWallet([deployerAccount], {
212-
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
213-
delegator: {
214-
delegatorPrivateKey: gasPayerAccount.privateKey
212+
gasPayer: {
213+
gasPayerPrivateKey: gasPayerAccount.privateKey
215214
}
216215
}),
217216
true

docs/diagrams/architecture/transaction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ classDiagram
3434
+Address origin
3535
+Uint8Array signature?
3636
+Transaction decode(Uint8Array rawTransaction, boolean isSigned)$
37-
+Blake2b256 getTransactionHash(Address delegator?)
37+
+Blake2b256 getTransactionHash(Address gasPayer?)
3838
+VTHO intrinsicGas(TransactionClause[] clauses)$
3939
+boolean isValidBody(TransactionBody body)$
4040
+Transaction of(TransactionBody: body, Uint8Array signature?)$

docs/examples/contracts/contract-delegation-ERC20.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import {
55
type ProviderInternalWalletAccount,
66
THOR_SOLO_URL,
77
ThorClient,
8-
type TransactionReceipt,
9-
VeChainProvider,
10-
type VeChainSigner
8+
VeChainProvider
119
} from '@vechain/sdk-network';
1210
import { expect } from 'expect';
1311

@@ -36,9 +34,8 @@ const thorSoloClient = ThorClient.at(THOR_SOLO_URL);
3634
const provider = new VeChainProvider(
3735
thorSoloClient,
3836
new ProviderInternalBaseWallet([deployerAccount], {
39-
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
40-
delegator: {
41-
delegatorPrivateKey: gasPayerAccount.privateKey
37+
gasPayer: {
38+
gasPayerPrivateKey: gasPayerAccount.privateKey
4239
}
4340
}),
4441
true

docs/examples/transactions/full-flow-delegator-private-key.ts docs/examples/transactions/full-flow-gas-payer-private-key.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from '@vechain/sdk-network';
1616
import { expect } from 'expect';
1717

18-
// START_SNIPPET: FullFlowDelegatorPrivateKeySnippet
18+
// START_SNIPPET: FullFlowGasPayerPrivateKeySnippet
1919

2020
// 1 - Create the thor client
2121
const thorSoloClient = ThorClient.at(THOR_SOLO_URL, {
@@ -50,9 +50,8 @@ const providerWithDelegationEnabled = new VeChainProvider(
5050
}
5151
],
5252
{
53-
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
54-
delegator: {
55-
delegatorPrivateKey: gasPayerAccount.privateKey
53+
gasPayer: {
54+
gasPayerPrivateKey: gasPayerAccount.privateKey
5655
}
5756
}
5857
),
@@ -115,7 +114,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction(
115114
sendTransactionResult.id
116115
);
117116

118-
// END_SNIPPET: FullFlowDelegatorPrivateKeySnippet
117+
// END_SNIPPET: FullFlowGasPayerPrivateKeySnippet
119118

120119
// Check the signed transaction
121120
expect(delegatedSigned.isSigned).toEqual(true);

docs/examples/transactions/full-flow-delegator-url.ts docs/examples/transactions/full-flow-gas-payer-service-url.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from '@vechain/sdk-network';
1616
import { expect } from 'expect';
1717

18-
// START_SNIPPET: FullFlowDelegatorUrlSnippet
18+
// START_SNIPPET: FullFlowGasPayerServiceUrlSnippet
1919

2020
// 1 - Create the thor client
2121
const thorClient = ThorClient.at(TESTNET_URL, {
@@ -54,9 +54,8 @@ const providerWithDelegationEnabled = new VeChainProvider(
5454
}
5555
],
5656
{
57-
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
58-
delegator: {
59-
delegatorUrl: gasPayerAccount.URL
57+
gasPayer: {
58+
gasPayerServiceUrl: gasPayerAccount.URL
6059
}
6160
}
6261
),
@@ -119,12 +118,12 @@ const txReceipt = await thorClient.transactions.waitForTransaction(
119118
sendTransactionResult.id
120119
);
121120

122-
// END_SNIPPET: FullFlowDelegatorUrlSnippet
121+
// END_SNIPPET: FullFlowGasPayerServiceUrlSnippet
123122

124123
// Check the signed transaction
125124
expect(delegatedSigned.isSigned).toEqual(true);
126125
expect(delegatedSigned.isDelegated).toEqual(true);
127-
// expect(signedTx.delegator).toEqual(gasPayerAccount.address); ---
126+
// expect(signedTx.gasPayer).toEqual(gasPayerAccount.address); ---
128127

129128
// Check the transaction receipt
130129
expect(txReceipt).toBeDefined();

docs/examples/transactions/full-flow-no-delegator.ts docs/examples/transactions/full-flow-no-gas-payer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from '@vechain/sdk-network';
1616
import { expect } from 'expect';
1717

18-
// START_SNIPPET: FullFlowNoDelegatorSnippet
18+
// START_SNIPPET: FullFlowNoGasPayerSnippet
1919

2020
// 1 - Create the thor client
2121
const thorSoloClient = ThorClient.at(THOR_SOLO_URL, {
@@ -95,7 +95,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction(
9595
sendTransactionResult.id
9696
);
9797

98-
// END_SNIPPET: FullFlowNoDelegatorSnippet
98+
// END_SNIPPET: FullFlowNoGasPayerSnippet
9999

100100
// Check the transaction receipt
101101
expect(txReceipt).toBeDefined();

docs/templates/transactions.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ In the following complete examples, we will explore the entire lifecycle of a Ve
5454

5555
1. **No Delegation (Signing Only with an Origin Private Key)**: In this scenario, we'll demonstrate the basic process of creating a transaction, signing it with the origin private key, and sending it to the VeChainThor blockchain without involving fee delegation.
5656

57-
[FullFlowNoDelegatorSnippet](examples/transactions/full-flow-no-delegator.ts)
57+
[FullFlowNoGasPayerSnippet](examples/transactions/full-flow-no-gas-payer.ts)
5858

59-
2. **Delegation with Private Key**: Here, we'll extend the previous example by incorporating fee delegation. The transaction sender will delegate the transaction fee payment to another entity (delegator), and we'll guide you through the steps of building, signing, and sending such a transaction.
59+
2. **Delegation with Private Key**: Here, we'll extend the previous example by incorporating fee delegation. The transaction sender will delegate the transaction fee payment to another entity (gasPayer), and we'll guide you through the steps of building, signing, and sending such a transaction.
6060

61-
[FullFlowDelegatorPrivateKeySnippet](examples/transactions/full-flow-delegator-private-key.ts)
61+
[FullFlowGasPayerPrivateKeySnippet](examples/transactions/full-flow-gas-payer-private-key.ts)
6262

6363
3. **Delegation with URL**: This example will showcase the use of a delegation URL for fee delegation. The sender will specify a delegation URL in the `signTransaction` options, allowing a designated sponsor to pay the transaction fee. We'll cover the full process, from building clauses to verifying the transaction on-chain.
6464

65-
[FullFlowDelegatorUrlSnippet](examples/transactions/full-flow-delegator-url.ts)
65+
[FullFlowGasPayerServiceUrlSnippet](examples/transactions/full-flow-gas-payer-service-url.ts)
6666

6767
By examining these complete examples, developers can gain a comprehensive understanding of transaction handling in the VeChain SDK. Each example demonstrates the steps involved in initiating, signing, and sending transactions, as well as the nuances associated with fee delegation.
6868

@@ -78,4 +78,4 @@ Even when using the `simulateTransaction` method you can find the revert reason.
7878

7979
[RevertReasonSimulationSnippet](examples/transactions/revert-reason-with-simulation.ts)
8080

81-
In this case there is only a `TransactionSimulationResult`, so no need to loop.
81+
In this case there is only a `TransactionSimulationResult`, so no need to loop.

0 commit comments

Comments
 (0)