Skip to content

Commit

Permalink
feat(sdk-coin-icp): Consume payload api added
Browse files Browse the repository at this point in the history
TICKET: WIN-4248
  • Loading branch information
mohd-kashif committed Jan 31, 2025
1 parent cf7c991 commit 2c868b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion modules/sdk-coin-icp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"@dfinity/candid": "^2.2.0",
"@dfinity/principal": "^2.2.0",
"crc-32": "^1.2.2",
"elliptic": "^6.6.1"
"elliptic": "^6.6.1",
"superagent": "^10.1.1"
},
"devDependencies": {
"@bitgo/sdk-api": "^1.58.5",
Expand Down
12 changes: 6 additions & 6 deletions modules/sdk-coin-icp/src/icp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import utils from './lib/utils';
import { IcpTransaction } from './lib/iface';
import request from 'superagent';

const PAYLOADS_API_PATH = '/construction/payloads';

/**
* Class representing the Internet Computer (ICP) coin.
* Extends the BaseCoin class and provides specific implementations for ICP.
Expand Down Expand Up @@ -125,16 +127,14 @@ export class Icp extends BaseCoin {
}

/** @inheritDoc **/
getPublicNodeUrl(): string {
public getPublicNodeUrl(): string {
return Environments[this.bitgo.getEnv()].rosettaNodeURL;
}

async consumePayloadsApi(payload: IcpTransaction): Promise<any> {
public async consumePayloadsApi(payload: IcpTransaction): Promise<request.Response> {
try {
const apiUrl = this.getPublicNodeUrl();
const response = await request.post(apiUrl).send(payload).set(utils.getHeaders());

return response.body;
const apiUrl = this.getPublicNodeUrl() + PAYLOADS_API_PATH;
return await request.post(apiUrl).send(payload).set(utils.getHeaders());
} catch (error) {
throw new Error(`Error consuming Payloads API: ${error.message || error}`);
}
Expand Down
1 change: 0 additions & 1 deletion modules/sdk-coin-icp/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as agent from '@dfinity/agent';
import crypto from 'crypto';
import crc32 from 'crc-32';
import { IcpNetworkIdentifier } from './iface';

const Secp256k1Curve = new elliptic.ec('secp256k1');

export class Utils implements BaseUtils {
Expand Down

0 comments on commit 2c868b8

Please sign in to comment.