Skip to content

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Jan 30, 2026

Adds the basic implementation for the Proton blockchain (XPR Network) including key pair generation, address validation, and transaction signing structures. Implements support for both mainnet (xpr) and testnet (txpr) networks.

Co-authored-by: llm-git llm-git@ttll.de

Ticket: BG-0

@lcovar lcovar changed the title feat(sdk): add new module for Proton (XPR Network) coin feat: add xrp coin Jan 30, 2026
- Add sdk-coin-xpr module with transaction builders
- Add XPR to statics (CoinFamily, networks, coins)
- Implement keyPair, transaction, transferBuilder
- Add unit tests

import { DefaultKeys, isPrivateKey, isPublicKey, isSeed, KeyPairOptions, AddressFormat } from '@bitgo/sdk-core';
import { PrivateKey, PublicKey, KeyType } from '@greymass/eosio';
import { randomBytes } from 'crypto';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import randomBytes.

Copilot Autofix

AI about 11 hours ago

In general, unused imports should be removed to improve readability and avoid confusion. Since randomBytes is never used and crypto is accessed via require('crypto') in the function body instead, the best fix is to delete the unused named import.

Concretely, in modules/sdk-coin-xpr/src/lib/keyPair.ts, remove line 7:

import { randomBytes } from 'crypto';

No other changes are required: the existing require('crypto') calls will continue to work, and there is no impact on current behavior since randomBytes was never referenced.


Suggested changeset 1
modules/sdk-coin-xpr/src/lib/keyPair.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/lib/keyPair.ts b/modules/sdk-coin-xpr/src/lib/keyPair.ts
--- a/modules/sdk-coin-xpr/src/lib/keyPair.ts
+++ b/modules/sdk-coin-xpr/src/lib/keyPair.ts
@@ -4,7 +4,6 @@
 
 import { DefaultKeys, isPrivateKey, isPublicKey, isSeed, KeyPairOptions, AddressFormat } from '@bitgo/sdk-core';
 import { PrivateKey, PublicKey, KeyType } from '@greymass/eosio';
-import { randomBytes } from 'crypto';
 
 /**
  * Proton (XPR Network) key pair class
EOF
@@ -4,7 +4,6 @@

import { DefaultKeys, isPrivateKey, isPublicKey, isSeed, KeyPairOptions, AddressFormat } from '@bitgo/sdk-core';
import { PrivateKey, PublicKey, KeyType } from '@greymass/eosio';
import { randomBytes } from 'crypto';

/**
* Proton (XPR Network) key pair class
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +14 to +22
import {
Transaction as EosioTransaction,
Checksum256,
Serializer,
Action,
Name,
Asset,
Struct,
} from '@greymass/eosio';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import Action.

Copilot Autofix

AI about 11 hours ago

To fix an unused import, remove the specific symbol from the import list while keeping all other used imports intact. This improves readability and avoids confusion without affecting functionality.

Concretely, in modules/sdk-coin-xpr/src/lib/transaction.ts, edit the import from @greymass/eosio (around lines 15–22). Remove Action from the curly-brace import list, keeping Transaction as EosioTransaction, Checksum256, Serializer, Name, Asset, and Struct unchanged. No other code changes or new imports are required.

Suggested changeset 1
modules/sdk-coin-xpr/src/lib/transaction.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/lib/transaction.ts b/modules/sdk-coin-xpr/src/lib/transaction.ts
--- a/modules/sdk-coin-xpr/src/lib/transaction.ts
+++ b/modules/sdk-coin-xpr/src/lib/transaction.ts
@@ -15,7 +15,6 @@
   Transaction as EosioTransaction,
   Checksum256,
   Serializer,
-  Action,
   Name,
   Asset,
   Struct,
EOF
@@ -15,7 +15,6 @@
Transaction as EosioTransaction,
Checksum256,
Serializer,
Action,
Name,
Asset,
Struct,
Copilot is powered by AI and may make mistakes. Always verify output.
import BigNumber from 'bignumber.js';
import { KeyPair } from './keyPair';
import { TxData, TransactionExplanation, BroadcastFormat, TransferActionData } from './iface';
import { MAINNET_CHAIN_ID, TESTNET_CHAIN_ID, TOKEN_CONTRACT, XPR_SYMBOL, XPR_PRECISION } from './constants';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import XPR_SYMBOL.

Copilot Autofix

AI about 11 hours ago

In general, unused imports should be removed to improve readability and avoid confusion. Since only XPR_SYMBOL is reported as unused while the other imports on the same line may be used elsewhere, the best minimal fix is to delete XPR_SYMBOL from the import list and leave the others unchanged.

Concretely, in modules/sdk-coin-xpr/src/lib/transaction.ts, adjust the import statement on line 26 so that it no longer includes XPR_SYMBOL. No additional methods, definitions, or imports are needed; this is purely a cleanup change to the existing import list.

Suggested changeset 1
modules/sdk-coin-xpr/src/lib/transaction.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/lib/transaction.ts b/modules/sdk-coin-xpr/src/lib/transaction.ts
--- a/modules/sdk-coin-xpr/src/lib/transaction.ts
+++ b/modules/sdk-coin-xpr/src/lib/transaction.ts
@@ -23,7 +23,7 @@
 import BigNumber from 'bignumber.js';
 import { KeyPair } from './keyPair';
 import { TxData, TransactionExplanation, BroadcastFormat, TransferActionData } from './iface';
-import { MAINNET_CHAIN_ID, TESTNET_CHAIN_ID, TOKEN_CONTRACT, XPR_SYMBOL, XPR_PRECISION } from './constants';
+import { MAINNET_CHAIN_ID, TESTNET_CHAIN_ID, TOKEN_CONTRACT, XPR_PRECISION } from './constants';
 
 /**
  * Define the transfer struct for eosio.token
EOF
@@ -23,7 +23,7 @@
import BigNumber from 'bignumber.js';
import { KeyPair } from './keyPair';
import { TxData, TransactionExplanation, BroadcastFormat, TransferActionData } from './iface';
import { MAINNET_CHAIN_ID, TESTNET_CHAIN_ID, TOKEN_CONTRACT, XPR_SYMBOL, XPR_PRECISION } from './constants';
import { MAINNET_CHAIN_ID, TESTNET_CHAIN_ID, TOKEN_CONTRACT, XPR_PRECISION } from './constants';

/**
* Define the transfer struct for eosio.token
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +13 to +23
import {
Transaction as EosioTransaction,
Action,
Name,
Asset,
Serializer,
UInt16,
UInt32,
TimePointSec,
Struct,
} from '@greymass/eosio';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused imports Action, Serializer, TimePointSec, UInt16, UInt32.

Copilot Autofix

AI about 11 hours ago

In general, unused imports should be removed from the module to reduce clutter and avoid confusion. Since they are not referenced anywhere in transactionBuilder.ts, deleting them will not affect existing functionality.

Specifically, in modules/sdk-coin-xpr/src/lib/transactionBuilder.ts, we should edit the import from @greymass/eosio on lines 13–23. Remove the unused symbols Action, Serializer, TimePointSec, UInt16, and UInt32 from the destructured import list, leaving only the actually used Transaction as EosioTransaction, Name, Asset, and Struct. No further code changes or additional imports are required.

Suggested changeset 1
modules/sdk-coin-xpr/src/lib/transactionBuilder.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts b/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
--- a/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
+++ b/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
@@ -12,13 +12,8 @@
 import { BaseCoin as CoinConfig } from '@bitgo/statics';
 import {
   Transaction as EosioTransaction,
-  Action,
   Name,
   Asset,
-  Serializer,
-  UInt16,
-  UInt32,
-  TimePointSec,
   Struct,
 } from '@greymass/eosio';
 import BigNumber from 'bignumber.js';
EOF
@@ -12,13 +12,8 @@
import { BaseCoin as CoinConfig } from '@bitgo/statics';
import {
Transaction as EosioTransaction,
Action,
Name,
Asset,
Serializer,
UInt16,
UInt32,
TimePointSec,
Struct,
} from '@greymass/eosio';
import BigNumber from 'bignumber.js';
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +28 to +35
import {
MAINNET_CHAIN_ID,
TESTNET_CHAIN_ID,
TOKEN_CONTRACT,
XPR_SYMBOL,
XPR_PRECISION,
DEFAULT_EXPIRATION_SECONDS,
} from './constants';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused imports TOKEN_CONTRACT, XPR_PRECISION, XPR_SYMBOL.

Copilot Autofix

AI about 11 hours ago

In general, unused imports should be removed to improve readability and avoid confusion. Since these constants are not used anywhere in the shown code, the best fix is to delete them from the import list while keeping the other, used constants.

Concretely, in modules/sdk-coin-xpr/src/lib/transactionBuilder.ts, adjust the import { ... } from './constants'; statement so that it only imports MAINNET_CHAIN_ID, TESTNET_CHAIN_ID, and DEFAULT_EXPIRATION_SECONDS, and no longer mentions TOKEN_CONTRACT, XPR_SYMBOL, or XPR_PRECISION. No additional methods, imports, or definitions are needed; we are only narrowing the import list.

Suggested changeset 1
modules/sdk-coin-xpr/src/lib/transactionBuilder.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts b/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
--- a/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
+++ b/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
@@ -28,9 +28,6 @@
 import {
   MAINNET_CHAIN_ID,
   TESTNET_CHAIN_ID,
-  TOKEN_CONTRACT,
-  XPR_SYMBOL,
-  XPR_PRECISION,
   DEFAULT_EXPIRATION_SECONDS,
 } from './constants';
 
EOF
@@ -28,9 +28,6 @@
import {
MAINNET_CHAIN_ID,
TESTNET_CHAIN_ID,
TOKEN_CONTRACT,
XPR_SYMBOL,
XPR_PRECISION,
DEFAULT_EXPIRATION_SECONDS,
} from './constants';

Copilot is powered by AI and may make mistakes. Always verify output.
/**
* Define the transfer struct for eosio.token
*/
class Transfer extends Struct {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused class Transfer.

Copilot Autofix

AI about 11 hours ago

To fix the problem, remove the unused Transfer class definition so that there is no dead code in the module. This does not affect the existing, visible functionality of the TransactionBuilder class, since nothing in the shown code references Transfer.

Concretely, in modules/sdk-coin-xpr/src/lib/transactionBuilder.ts, delete the block that defines Transfer (lines 37–48 in the snippet: the comment and the class body). No additional imports, methods, or definitions are required, and no other lines need to be changed.

Suggested changeset 1
modules/sdk-coin-xpr/src/lib/transactionBuilder.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts b/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
--- a/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
+++ b/modules/sdk-coin-xpr/src/lib/transactionBuilder.ts
@@ -34,19 +34,19 @@
   DEFAULT_EXPIRATION_SECONDS,
 } from './constants';
 
-/**
- * Define the transfer struct for eosio.token
- */
-class Transfer extends Struct {
-  static abiName = 'transfer';
-  static abiFields = [
-    { name: 'from', type: Name },
-    { name: 'to', type: Name },
-    { name: 'quantity', type: Asset },
-    { name: 'memo', type: 'string' },
-  ];
-}
 
+
+
+
+
+
+
+
+
+
+
+
+
 export abstract class TransactionBuilder extends BaseTransactionBuilder {
   protected _transaction: Transaction;
   protected _sender: string;
EOF
@@ -34,19 +34,19 @@
DEFAULT_EXPIRATION_SECONDS,
} from './constants';

/**
* Define the transfer struct for eosio.token
*/
class Transfer extends Struct {
static abiName = 'transfer';
static abiFields = [
{ name: 'from', type: Name },
{ name: 'to', type: Name },
{ name: 'quantity', type: Asset },
{ name: 'memo', type: 'string' },
];
}













export abstract class TransactionBuilder extends BaseTransactionBuilder {
protected _transaction: Transaction;
protected _sender: string;
Copilot is powered by AI and may make mistakes. Always verify output.
AuditDecryptedKeyParams,
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import { KeyPair as XprKeyPair, Transaction, TransferBuilder } from './lib';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import TransferBuilder.

Copilot Autofix

AI about 11 hours ago

To fix this, remove the unused TransferBuilder named import from the ./lib import statement, leaving only the identifiers that are actually used (KeyPair as XprKeyPair and Transaction). This eliminates dead code, clarifies dependencies, and aligns with the recommendation to remove unused program elements.

Concretely, in modules/sdk-coin-xpr/src/xpr.ts, edit the import on line 19 so that it no longer imports TransferBuilder. No additional methods, imports, or definitions are required; we’re only trimming the unused symbol from an existing import.

Suggested changeset 1
modules/sdk-coin-xpr/src/xpr.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/xpr.ts b/modules/sdk-coin-xpr/src/xpr.ts
--- a/modules/sdk-coin-xpr/src/xpr.ts
+++ b/modules/sdk-coin-xpr/src/xpr.ts
@@ -16,7 +16,7 @@
   AuditDecryptedKeyParams,
 } from '@bitgo/sdk-core';
 import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
-import { KeyPair as XprKeyPair, Transaction, TransferBuilder } from './lib';
+import { KeyPair as XprKeyPair, Transaction } from './lib';
 import utils from './lib/utils';
 import { MAINNET_CHAIN_ID, XPR_PRECISION } from './lib/constants';
 
EOF
@@ -16,7 +16,7 @@
AuditDecryptedKeyParams,
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import { KeyPair as XprKeyPair, Transaction, TransferBuilder } from './lib';
import { KeyPair as XprKeyPair, Transaction } from './lib';
import utils from './lib/utils';
import { MAINNET_CHAIN_ID, XPR_PRECISION } from './lib/constants';

Copilot is powered by AI and may make mistakes. Always verify output.
* @returns {boolean}
*/
async verifyTransaction(params: XprVerifyTransactionOptions): Promise<boolean> {
const { txPrebuild, txParams } = params;

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable txParams.

Copilot Autofix

AI about 11 hours ago

To fix the problem, remove the unused txParams binding from the destructuring assignment so the function only declares variables it actually uses. This maintains the existing function signature and behavior (it still receives params, still validates only txPrebuild.txHex, and still returns true), while eliminating the unused local variable.

Concretely, in modules/sdk-coin-xpr/src/xpr.ts, inside the verifyTransaction method, change the line:

const { txPrebuild, txParams } = params;

to:

const { txPrebuild } = params;

No new imports, methods, or additional code are required; this is a minimal, behavior-preserving cleanup.

Suggested changeset 1
modules/sdk-coin-xpr/src/xpr.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-xpr/src/xpr.ts b/modules/sdk-coin-xpr/src/xpr.ts
--- a/modules/sdk-coin-xpr/src/xpr.ts
+++ b/modules/sdk-coin-xpr/src/xpr.ts
@@ -174,7 +174,7 @@
    * @returns {boolean}
    */
   async verifyTransaction(params: XprVerifyTransactionOptions): Promise<boolean> {
-    const { txPrebuild, txParams } = params;
+    const { txPrebuild } = params;
 
     if (!txPrebuild?.txHex) {
       throw new Error('Missing txPrebuild.txHex');
EOF
@@ -174,7 +174,7 @@
* @returns {boolean}
*/
async verifyTransaction(params: XprVerifyTransactionOptions): Promise<boolean> {
const { txPrebuild, txParams } = params;
const { txPrebuild } = params;

if (!txPrebuild?.txHex) {
throw new Error('Missing txPrebuild.txHex');
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants