Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@collabland/chain

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@collabland/chain - npm Package Compare versions

Comparing version 0.14.5 to 0.15.0

dist/ipfs.d.ts

5

dist/base-connector.d.ts

@@ -0,5 +1,6 @@

import { AssetMetadata, AssetResource } from '.';
import { AssetName, AssetTypeParams } from './caip';
import { ChainConnector } from './chain-connector';
import { AccountIdResource, AssetResource, ChainIdResource } from './chain-resource';
import { Amount, AssetMetadata, AssetRequest, AssetResponse, ChainOptions, ChainType, NativeCurrency, NFTAssetOptions, TokenAsset, TokenId, TokenMetadata } from './types';
import { AccountIdResource, ChainIdResource } from './chain-resource';
import { Amount, AssetRequest, AssetResponse, ChainOptions, ChainType, NativeCurrency, NFTAssetOptions, TokenAsset, TokenId, TokenMetadata } from './types';
/**

@@ -6,0 +7,0 @@ * Base chain connector

68

dist/base-connector.js

@@ -12,2 +12,3 @@ "use strict";

const chain_resource_1 = require("./chain-resource");
const ipfs_1 = require("./ipfs");
const types_1 = require("./types");

@@ -83,29 +84,42 @@ const debug = (0, common_1.debugFactory)('collabland:connector');

});
if (this.isNative(req.namespace)) {
const nativeBalance = await this.getBalance(account);
asset = { balance: nativeBalance, asset: assetUri };
return asset;
try {
if (this.isNative(req.namespace)) {
const nativeBalance = await this.getBalance(account);
asset = { balance: nativeBalance, asset: assetUri };
return asset;
}
else if (req.namespace.toLowerCase() === 'ft' ||
(await this.isFT(req.namespace))) {
const ftBalance = await this.getFTBalance(account, assetName);
asset = { balance: ftBalance, asset: assetUri };
return asset;
}
else if (req.namespace.toLowerCase() === 'nft' ||
(await this.isNFT(req.namespace))) {
const metadata = (_b = req.metadata) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.metadata;
const nftOptions = {
tokenId,
metadata: metadata !== false,
};
const nfts = await this.getNFTBalance(account, assetName, nftOptions);
asset = {
balance: this.toAmount(nfts.length),
tokens: nfts,
asset: assetUri,
};
return asset;
}
throw new common_1.HttpErrors.BadRequest(`Invalid asset request: ${assetName}/${req.tokenId}`);
}
else if (req.namespace.toLowerCase() === 'ft' ||
(await this.isFT(req.namespace))) {
const ftBalance = await this.getFTBalance(account, assetName);
asset = { balance: ftBalance, asset: assetUri };
return asset;
catch (err) {
debug('Fail to get balance of %s for %s: %O', assetUri, account, err);
if (err.code === 'CALL_EXCEPTION') {
return {
balance: this.toAmount(0),
tokens: [],
asset: assetUri,
};
}
throw err;
}
else if (req.namespace.toLowerCase() === 'nft' ||
(await this.isNFT(req.namespace))) {
const metadata = (_b = req.metadata) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.metadata;
const nftOptions = {
tokenId,
metadata: metadata !== false,
};
const nfts = await this.getNFTBalance(account, assetName, nftOptions);
asset = {
balance: this.toAmount(nfts.length),
tokens: nfts,
asset: assetUri,
};
return asset;
}
throw new common_1.HttpErrors.BadRequest(`Invalid asset request: ${assetName}/${req.tokenId}`);
}, { concurrency: this.concurrency });

@@ -137,6 +151,6 @@ debug('Assets: %s', (0, common_1.stringify)(assets));

if (url.startsWith('ipfs://')) {
const ipfsGateway = (0, common_1.getEnvVar)('IPFS_GATEWAY_URL', 'https://ipfs.io');
const ipfsGateway = (0, common_1.getEnvVar)('IPFS_GATEWAY_URL', 'https://collabland.mypinata.cloud');
// https://{gateway URL}/ipfs/{CID}/{optional path to resource}
// https://{CID}.ipfs.{gatewayURL}/{optional path to resource}
url = url.replace('ipfs://', `${ipfsGateway}/`);
url = (0, ipfs_1.getIPFSGatewayUrl)(url, ipfsGateway);
debug('IPFS http url: %s', url);

@@ -143,0 +157,0 @@ }

@@ -12,4 +12,4 @@ "use strict";

// See https://github.com/ChainAgnostic/CAIPs/issues/63
const assetReference = '[-a-zA-Z0-9._]{1,64}';
const accountAddress = '[a-zA-Z0-9._]{1,64}';
const assetReference = '[-a-zA-Z0-9._]{1,128}';
const accountAddress = '[a-zA-Z0-9._]{1,128}';
/**

@@ -16,0 +16,0 @@ * Extension: we want to allow multiple token ids, such as `1-100` or `1,3,100`.

{
"name": "@collabland/chain",
"version": "0.14.5",
"version": "0.15.0",
"description": "CollabLand Ethereum Integration",

@@ -34,15 +34,16 @@ "main": "dist/index.js",

"dependencies": {
"@collabland/common": "^0.25.2",
"@collabland/common": "^0.26.0",
"is-ipfs": "^6.0.2",
"tslib": "^2.0.0"
},
"devDependencies": {
"@loopback/build": "^7.0.1",
"@loopback/eslint-config": "^11.0.1",
"@loopback/testlab": "^3.4.3",
"@loopback/build": "^7.0.2",
"@loopback/eslint-config": "^11.0.2",
"@loopback/testlab": "^3.4.4",
"@types/node": "^12.12.6",
"typescript": "~4.4.2"
"typescript": "~4.4.4"
},
"copyright.owner": "Abridged, Inc.",
"author": "Abridged, Inc.",
"gitHead": "3b88a84c0572e426788dcf3632a73ea06fbd2a17"
"gitHead": "2fb2a2a33b8afa9d6208ddac65c4ddc6dd66dca8"
}

@@ -16,2 +16,3 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved.

} from '@collabland/common';
import {AssetMetadata, AssetResource} from '.';
import {AssetName, AssetTypeParams} from './caip';

@@ -22,3 +23,2 @@ import {AssetNameId} from './caip/asset-name-id';

AccountIdResource,
AssetResource,
ChainIdResource,

@@ -28,5 +28,5 @@ getChainUri,

} from './chain-resource';
import {getIPFSGatewayUrl} from './ipfs';
import {
Amount,
AssetMetadata,
AssetRequest,

@@ -154,33 +154,49 @@ AssetResponse,

});
if (this.isNative(req.namespace)) {
const nativeBalance = await this.getBalance(account);
asset = {balance: nativeBalance, asset: assetUri};
return asset;
} else if (
req.namespace.toLowerCase() === 'ft' ||
(await this.isFT(req.namespace))
) {
const ftBalance = await this.getFTBalance(account, assetName);
asset = {balance: ftBalance, asset: assetUri};
return asset;
} else if (
req.namespace.toLowerCase() === 'nft' ||
(await this.isNFT(req.namespace))
) {
const metadata = req.metadata ?? options?.metadata;
const nftOptions: NFTAssetOptions = {
tokenId,
metadata: metadata !== false,
};
const nfts = await this.getNFTBalance(account, assetName, nftOptions);
asset = {
balance: this.toAmount(nfts.length),
tokens: nfts,
asset: assetUri,
};
return asset;
try {
if (this.isNative(req.namespace)) {
const nativeBalance = await this.getBalance(account);
asset = {balance: nativeBalance, asset: assetUri};
return asset;
} else if (
req.namespace.toLowerCase() === 'ft' ||
(await this.isFT(req.namespace))
) {
const ftBalance = await this.getFTBalance(account, assetName);
asset = {balance: ftBalance, asset: assetUri};
return asset;
} else if (
req.namespace.toLowerCase() === 'nft' ||
(await this.isNFT(req.namespace))
) {
const metadata = req.metadata ?? options?.metadata;
const nftOptions: NFTAssetOptions = {
tokenId,
metadata: metadata !== false,
};
const nfts = await this.getNFTBalance(
account,
assetName,
nftOptions,
);
asset = {
balance: this.toAmount(nfts.length),
tokens: nfts,
asset: assetUri,
};
return asset;
}
throw new HttpErrors.BadRequest(
`Invalid asset request: ${assetName}/${req.tokenId}`,
);
} catch (err: AnyError) {
debug('Fail to get balance of %s for %s: %O', assetUri, account, err);
if (err.code === 'CALL_EXCEPTION') {
return {
balance: this.toAmount(0),
tokens: [],
asset: assetUri,
};
}
throw err;
}
throw new HttpErrors.BadRequest(
`Invalid asset request: ${assetName}/${req.tokenId}`,
);
},

@@ -222,6 +238,9 @@ {concurrency: this.concurrency},

if (url.startsWith('ipfs://')) {
const ipfsGateway = getEnvVar('IPFS_GATEWAY_URL', 'https://ipfs.io');
const ipfsGateway = getEnvVar(
'IPFS_GATEWAY_URL',
'https://collabland.mypinata.cloud',
);
// https://{gateway URL}/ipfs/{CID}/{optional path to resource}
// https://{CID}.ipfs.{gatewayURL}/{optional path to resource}
url = url.replace('ipfs://', `${ipfsGateway}/`);
url = getIPFSGatewayUrl(url, ipfsGateway!);
debug('IPFS http url: %s', url);

@@ -228,0 +247,0 @@ }

@@ -13,4 +13,4 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved.

// See https://github.com/ChainAgnostic/CAIPs/issues/63
const assetReference = '[-a-zA-Z0-9._]{1,64}';
const accountAddress = '[a-zA-Z0-9._]{1,64}';
const assetReference = '[-a-zA-Z0-9._]{1,128}';
const accountAddress = '[a-zA-Z0-9._]{1,128}';

@@ -17,0 +17,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc