Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1658 bnc part 2 #1788

Merged
merged 46 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f842d6b
fix: fix BNC...
lucanicoladebiasi Jan 29, 2025
186667c
fix: fix BNC...
lucanicoladebiasi Jan 29, 2025
517e9cd
fix: fix BNC...
lucanicoladebiasi Jan 29, 2025
8743c13
fix: fix BNC...
lucanicoladebiasi Jan 29, 2025
c2f560c
fix: fix BNC...
lucanicoladebiasi Jan 30, 2025
6a5f9b1
fix: fix BNC...
lucanicoladebiasi Jan 30, 2025
74447ca
Merge branch 'main' into 1658-bnc
lucanicoladebiasi Jan 30, 2025
688b52f
Merge branch '1658-bnc' into 1658-bnc---part-2
lucanicoladebiasi Feb 4, 2025
c970688
Merge branch 'main' into 1658-bnc---part-2
lucanicoladebiasi Feb 5, 2025
c3b0ac3
fix: en_7 recommendations... (#1749)
lucanicoladebiasi Feb 5, 2025
1db6c95
fix: BNC (network)
lucanicoladebiasi Feb 6, 2025
41c5356
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
0f57e12
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
8a411a7
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
1b7076d
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
9a8965e
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
e39f0d4
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
be836d4
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
99bcb28
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
5666047
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
abfdab3
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
220008d
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
57e1dfe
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
3f54e7f
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
6283023
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
b22584c
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
fa764a2
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
40aba92
fix: BNC 2 network
lucanicoladebiasi Feb 6, 2025
4bd5d23
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
4a982dc
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
a057c1f
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
7b3ed2c
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
d45db89
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
593cd92
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
b16343b
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
f8cc404
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
6511531
Update packages/rpc-proxy/src/utils/config-validator/config-validator.ts
lucanicoladebiasi Feb 7, 2025
c576e85
Update packages/rpc-proxy/src/utils/config-validator/config-validator.ts
lucanicoladebiasi Feb 7, 2025
c5ea205
fix: BNC 2 network
lucanicoladebiasi Feb 7, 2025
105ca6c
fix: `BNC` part 2 - network refactor
lucanicoladebiasi Jan 31, 2025
2a73fd0
fix: `BNC` part 2 - network refactor
lucanicoladebiasi Feb 8, 2025
560c4e5
fix: `BNC` part 2 - network refactor
lucanicoladebiasi Feb 10, 2025
45278fb
fix: `BNC` part 2 - network refactor
lucanicoladebiasi Feb 10, 2025
961659e
fix: `BNC` part 2 - openssl fix
lucanicoladebiasi Feb 10, 2025
569ac46
fix: `BNC` part 2 - openssl fix
lucanicoladebiasi Feb 10, 2025
2f1f397
fix: `BNC` part 2 - rpc-proxy README.md amended
lucanicoladebiasi Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/rpc-proxy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
- name: Set up QEMU
if: ${{ github.event_name != 'pull_request' }}
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
if: ${{ github.event_name != 'pull_request' }}
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
Expand All @@ -36,7 +36,7 @@ jobs:
uses: docker/metadata-action@v5
with:
images: vechain/sdk-rpc-proxy

- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
Expand All @@ -48,8 +48,10 @@ jobs:

- name: Create .trivyignore file
# "cross-spawn" is resolved as version 7.0.5 but Trivy keeps showing the error
run: echo "CVE-2024-21538" > .trivyignore

run: |
echo "CVE-2024-21538" > .trivyignore
echo "CVE-2024-13176" >> .trivyignore

- name: Run Trivy Scan
uses: aquasecurity/trivy-action@master
with:
Expand All @@ -64,7 +66,7 @@ jobs:
env:
# See https://github.com/aquasecurity/trivy/discussions/7538
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2

- name: Build and push
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v6
Expand Down
2 changes: 1 addition & 1 deletion apps/sdk-cloudflare-integration/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
};

// Create private key
const privateKey = await Secp256k1.generatePrivateKey();
const privateKey = Secp256k1.generatePrivateKey();

// 4 - Sign transaction
const signedTransaction = Transaction.of(body).sign(privateKey);
Expand Down
6 changes: 3 additions & 3 deletions apps/sdk-hardhat-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ The `hardhat.config.js` is the main configuration file. By specifying the desire
Note that:

- The network name should contain `vechain`, otherwise, it may result in an error.
- 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.
- 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.
- **Debug Mode**: The `debug` field enables or disables debug mode.
- **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`.
- **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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Duplicate and outdated content in the bullet point.
The bullet point still refers to “Delegator” and repeats the description, which may cause confusion. To fully reflect the renaming effort, please update the text to mention that the gas payer supports parameters such as “gasPayerPrivateKey” and “gasPayerServiceUrl” (if applicable) and remove the repeated fragment.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

24-24: Unordered list indentation
Expected: 2; Actual: 3

(MD007, ul-indent)

- 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.

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.
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.
16 changes: 8 additions & 8 deletions apps/sdk-hardhat-integration/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { type HttpNetworkConfig } from 'hardhat/types';
*
* They have custom parameters:
* - debug: whether to enable debug mode
* - delegator: the delegator to use
* - gasPayer: the gasPayer to use
* - enableDelegation: whether to enable fee delegation
*/
const config: HardhatUserConfig = {
Expand Down Expand Up @@ -42,7 +42,7 @@ const config: HardhatUserConfig = {
'7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158'
],
debug: false,
delegator: undefined,
gasPayer: undefined,
gas: 'auto',
gasPrice: 'auto',
gasMultiplier: 1,
Expand All @@ -65,7 +65,7 @@ const config: HardhatUserConfig = {
passphrase: 'vechainthor'
},
debug: true,
delegator: undefined,
gasPayer: undefined,
gas: 'auto',
gasPrice: 'auto',
gasMultiplier: 1,
Expand All @@ -74,7 +74,7 @@ const config: HardhatUserConfig = {
} satisfies HttpNetworkConfig,

/**
* Testnet configuration - with delegator url
* Testnet configuration - with gasPayer url
*/
vechain_testnet_delegator_url: {
// Testnet
Expand All @@ -88,7 +88,7 @@ const config: HardhatUserConfig = {
passphrase: 'vechainthor'
},
debug: true,
delegator: {
gasPayer: {
delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269'
},
enableDelegation: true,
Expand All @@ -100,7 +100,7 @@ const config: HardhatUserConfig = {
} satisfies HttpNetworkConfig,

/**
* Testnet configuration - with delegator private key
* Testnet configuration - with gasPayer private key
*/
vechain_testnet_delegator_private_key: {
// Testnet
Expand All @@ -114,7 +114,7 @@ const config: HardhatUserConfig = {
passphrase: 'vechainthor'
},
debug: true,
delegator: {
gasPayer: {
delegatorPrivateKey:
'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5'
},
Expand All @@ -137,7 +137,7 @@ const config: HardhatUserConfig = {
],
debug: false,
enableDelegation: false,
delegator: undefined,
gasPayer: undefined,
gas: 'auto',
gasPrice: 'auto',
gasMultiplier: 1,
Expand Down
14 changes: 7 additions & 7 deletions docker-compose.rpc-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ services:

# Default configuration for the RPC proxy service
rpc-proxy:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
container_name: rpc-proxy
Expand All @@ -80,7 +80,7 @@ services:

# 1. Example of a custom configuration file for the RPC proxy service
rpc-proxy-custom-config-file:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
environment:
Expand All @@ -95,7 +95,7 @@ services:

# 2. Example of a custom parameters for the RPC proxy service
rpc-proxy-custom-parameters:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
environment:
Expand All @@ -110,7 +110,7 @@ services:

# 3. Example of a custom accounts for the RPC proxy service
rpc-proxy-custom-accounts:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
environment:
Expand All @@ -125,7 +125,7 @@ services:

# 3. Example of a custom mnemonic for the RPC proxy service
rpc-proxy-custom-mnemonic:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
environment:
Expand All @@ -142,7 +142,7 @@ services:

# 4. Example of a custom delegation by private key for the RPC proxy service
rpc-proxy-with-delegation-by-private-key:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
environment:
Expand All @@ -161,7 +161,7 @@ services:

# 5. Example of a custom delegation by url for the RPC proxy service
rpc-proxy-with-delegation-by-url:
build:
build:
context: .
dockerfile: docker/rpc-proxy/Dockerfile
environment:
Expand Down
4 changes: 2 additions & 2 deletions docker/rpc-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ COPY --from=builder /app/yarn.lock /app/yarn.lock
WORKDIR /app
RUN yarn workspace @vechain/sdk-rpc-proxy install --production --frozen-lockfile --ignore-scripts --prefer-offline \
&& yarn cache clean \
&& adduser -D rpc-proxy-user
&& adduser -D rpc-proxy-user
# Create a new user to run the app so we do not use root
USER rpc-proxy-user

# Tell we are running with Docker
ENV RUNNING_WITH_DOCKER=true

# Set the default command to use node to run the app
CMD ["node", "packages/rpc-proxy/dist/index.js"]
CMD ["node", "packages/rpc-proxy/dist/index.js"]
5 changes: 2 additions & 3 deletions docs/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ const thorSoloClient = ThorClient.at(THOR_SOLO_URL);
const provider = new VeChainProvider(
thorSoloClient,
new ProviderInternalBaseWallet([deployerAccount], {
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
delegator: {
delegatorPrivateKey: gasPayerAccount.privateKey
gasPayer: {
gasPayerPrivateKey: gasPayerAccount.privateKey
}
}),
true
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/architecture/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classDiagram
+Address origin
+Uint8Array signature?
+Transaction decode(Uint8Array rawTransaction, boolean isSigned)$
+Blake2b256 getTransactionHash(Address delegator?)
+Blake2b256 getTransactionHash(Address gasPayer?)
+VTHO intrinsicGas(TransactionClause[] clauses)$
+boolean isValidBody(TransactionBody body)$
+Transaction of(TransactionBody: body, Uint8Array signature?)$
Expand Down
9 changes: 3 additions & 6 deletions docs/examples/contracts/contract-delegation-ERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
type ProviderInternalWalletAccount,
THOR_SOLO_URL,
ThorClient,
type TransactionReceipt,
VeChainProvider,
type VeChainSigner
VeChainProvider
} from '@vechain/sdk-network';
import { expect } from 'expect';

Expand Down Expand Up @@ -36,9 +34,8 @@ const thorSoloClient = ThorClient.at(THOR_SOLO_URL);
const provider = new VeChainProvider(
thorSoloClient,
new ProviderInternalBaseWallet([deployerAccount], {
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
delegator: {
delegatorPrivateKey: gasPayerAccount.privateKey
gasPayer: {
gasPayerPrivateKey: gasPayerAccount.privateKey
}
}),
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@vechain/sdk-network';
import { expect } from 'expect';

// START_SNIPPET: FullFlowDelegatorPrivateKeySnippet
// START_SNIPPET: FullFlowGasPayerPrivateKeySnippet

// 1 - Create the thor client
const thorSoloClient = ThorClient.at(THOR_SOLO_URL, {
Expand Down Expand Up @@ -50,9 +50,8 @@ const providerWithDelegationEnabled = new VeChainProvider(
}
],
{
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
delegator: {
delegatorPrivateKey: gasPayerAccount.privateKey
gasPayer: {
gasPayerPrivateKey: gasPayerAccount.privateKey
}
}
),
Expand Down Expand Up @@ -115,7 +114,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction(
sendTransactionResult.id
);

// END_SNIPPET: FullFlowDelegatorPrivateKeySnippet
// END_SNIPPET: FullFlowGasPayerPrivateKeySnippet

// Check the signed transaction
expect(delegatedSigned.isSigned).toEqual(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@vechain/sdk-network';
import { expect } from 'expect';

// START_SNIPPET: FullFlowDelegatorUrlSnippet
// START_SNIPPET: FullFlowGasPayerServiceUrlSnippet

// 1 - Create the thor client
const thorClient = ThorClient.at(TESTNET_URL, {
Expand Down Expand Up @@ -54,9 +54,8 @@ const providerWithDelegationEnabled = new VeChainProvider(
}
],
{
// The term `delegator` will be deprecated soon and renamed `gasPayer`.
delegator: {
delegatorUrl: gasPayerAccount.URL
gasPayer: {
gasPayerServiceUrl: gasPayerAccount.URL
}
}
),
Expand Down Expand Up @@ -119,12 +118,12 @@ const txReceipt = await thorClient.transactions.waitForTransaction(
sendTransactionResult.id
);

// END_SNIPPET: FullFlowDelegatorUrlSnippet
// END_SNIPPET: FullFlowGasPayerServiceUrlSnippet

// Check the signed transaction
expect(delegatedSigned.isSigned).toEqual(true);
expect(delegatedSigned.isDelegated).toEqual(true);
// expect(signedTx.delegator).toEqual(gasPayerAccount.address); ---
// expect(signedTx.gasPayer).toEqual(gasPayerAccount.address); ---

// Check the transaction receipt
expect(txReceipt).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@vechain/sdk-network';
import { expect } from 'expect';

// START_SNIPPET: FullFlowNoDelegatorSnippet
// START_SNIPPET: FullFlowNoGasPayerSnippet

// 1 - Create the thor client
const thorSoloClient = ThorClient.at(THOR_SOLO_URL, {
Expand Down Expand Up @@ -95,7 +95,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction(
sendTransactionResult.id
);

// END_SNIPPET: FullFlowNoDelegatorSnippet
// END_SNIPPET: FullFlowNoGasPayerSnippet

// Check the transaction receipt
expect(txReceipt).toBeDefined();
Expand Down
10 changes: 5 additions & 5 deletions docs/templates/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ In the following complete examples, we will explore the entire lifecycle of a Ve

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.

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

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.
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.

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

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.

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

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.

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

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

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