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.16.0 to 0.17.0

1

dist/base-connector.d.ts

@@ -55,1 +55,2 @@ import { AssetMetadata, AssetResource } from '.';

}
export declare function fetchTokenMetadata<M extends TokenMetadata>(url?: string): Promise<M | undefined>;

45

dist/base-connector.js

@@ -7,3 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseChainConnector = void 0;
exports.fetchTokenMetadata = exports.BaseChainConnector = void 0;
const common_1 = require("@collabland/common");

@@ -144,20 +144,5 @@ const caip_1 = require("./caip");

async fetchMetadata(token) {
debug('Fetching token metadata for %O:', token);
let url = token.uri;
if (url) {
try {
const fetch = (0, common_1.getFetch)();
if (url.startsWith('ipfs://')) {
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 = (0, ipfs_1.getIPFSGatewayUrl)(url, ipfsGateway);
debug('IPFS http url: %s', url);
}
const res = await fetch(url);
token.metadata = await (0, common_1.handleFetchResponse)(res, 200);
}
catch (err) {
debug('Error in fetching %s', token.uri, err);
}
const metadata = await fetchTokenMetadata(token.uri);
if (metadata != null) {
token.metadata = metadata;
}

@@ -170,2 +155,24 @@ }

exports.BaseChainConnector = BaseChainConnector;
async function fetchTokenMetadata(url) {
debug('Fetching token metadata for %s:', url);
if (url) {
try {
const fetch = (0, common_1.getFetch)();
if (url.startsWith('ipfs://')) {
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 = (0, ipfs_1.getIPFSGatewayUrl)(url, ipfsGateway);
debug('IPFS http url: %s', url);
}
const res = await fetch(url);
const metadata = await (0, common_1.handleFetchResponse)(res, 200);
return metadata;
}
catch (err) {
debug('Error in fetching %s', url, err);
}
}
}
exports.fetchTokenMetadata = fetchTokenMetadata;
//# sourceMappingURL=base-connector.js.map

@@ -51,8 +51,12 @@ "use strict";

try {
const from = new common_1.BN(range[0]);
const to = new common_1.BN(range[1]);
let i = new common_1.BN(from);
const from = common_1.BN.from(range[0]);
const to = common_1.BN.from(range[1]);
if (to.sub(from).gt(common_1.BN.from(10000))) {
debug('Token range exceeds 1000: [%s, %s]', from, to);
return undefined;
}
let i = common_1.BN.from(from);
while (i.lte(to)) {
result.push(i.toString());
i = i.add(new common_1.BN(1));
i = i.add(common_1.BN.from(1));
}

@@ -59,0 +63,0 @@ }

@@ -8,8 +8,8 @@ "use strict";

exports.CAIP = void 0;
// REVIEW(rfeng): It deviates from CAIP as we allow uppercase letters
const namespace = '[-a-zA-Z0-9]{3,8}';
const chainIdReference = '[-a-zA-Z0-9]{1,32}';
// REVIEW(rfeng): It deviates from CAIP as we allow uppercase letters, _, and .
const namespace = '[-a-zA-Z0-9._]{2,16}';
const chainIdReference = '[-a-zA-Z0-9._]{1,32}';
// See https://github.com/ChainAgnostic/CAIPs/issues/63
const assetReference = '[-a-zA-Z0-9._]{1,128}';
const accountAddress = '[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`.

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

const common_1 = require("@collabland/common");
const url_1 = require("url");
const caip_1 = require("./caip");

@@ -191,3 +192,3 @@ const debug = (0, common_1.debugFactory)('collabland:chain');

if (search != null) {
const params = new URLSearchParams(search);
const params = new url_1.URLSearchParams(search);
params.forEach((val, key) => {

@@ -194,0 +195,0 @@ query[key] = decodeURIComponent(val);

{
"name": "@collabland/chain",
"version": "0.16.0",
"version": "0.17.0",
"description": "CollabLand Ethereum Integration",

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

"dependencies": {
"@collabland/common": "^0.27.0",
"@collabland/common": "^0.28.0",
"is-ipfs": "^6.0.2",

@@ -48,3 +48,3 @@ "tslib": "^2.0.0"

"author": "Abridged, Inc.",
"gitHead": "8669002d6e5ea1b1011e5f985b32f00e939c1d15"
"gitHead": "86d1583aa3e44990cd3c13b5562a0100df3d7599"
}

@@ -228,22 +228,5 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved.

async fetchMetadata(token: TokenAsset<TID, M, AMT>) {
debug('Fetching token metadata for %O:', token);
let url = token.uri;
if (url) {
try {
const fetch = getFetch();
if (url.startsWith('ipfs://')) {
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 = getIPFSGatewayUrl(url, ipfsGateway!);
debug('IPFS http url: %s', url);
}
const res = await fetch(url);
token.metadata = await handleFetchResponse(res, 200);
} catch (err: AnyError) {
debug('Error in fetching %s', token.uri, err);
}
const metadata = await fetchTokenMetadata<M>(token.uri);
if (metadata != null) {
token.metadata = metadata;
}

@@ -256,1 +239,27 @@ }

}
export async function fetchTokenMetadata<M extends TokenMetadata>(
url?: string,
) {
debug('Fetching token metadata for %s:', url);
if (url) {
try {
const fetch = getFetch();
if (url.startsWith('ipfs://')) {
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 = getIPFSGatewayUrl(url, ipfsGateway!);
debug('IPFS http url: %s', url);
}
const res = await fetch(url);
const metadata = await handleFetchResponse<M>(res, 200);
return metadata;
} catch (err: AnyError) {
debug('Error in fetching %s', url, err);
}
}
}

@@ -56,8 +56,12 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved.

try {
const from = new BN(range[0]);
const to = new BN(range[1]);
let i = new BN(from);
const from = BN.from(range[0]);
const to = BN.from(range[1]);
if (to.sub(from).gt(BN.from(10000))) {
debug('Token range exceeds 1000: [%s, %s]', from, to);
return undefined;
}
let i = BN.from(from);
while (i.lte(to)) {
result.push(i.toString());
i = i.add(new BN(1));
i = i.add(BN.from(1));
}

@@ -64,0 +68,0 @@ } catch (err: AnyError) {

@@ -8,9 +8,9 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved.

// REVIEW(rfeng): It deviates from CAIP as we allow uppercase letters
const namespace = '[-a-zA-Z0-9]{3,8}';
const chainIdReference = '[-a-zA-Z0-9]{1,32}';
// REVIEW(rfeng): It deviates from CAIP as we allow uppercase letters, _, and .
const namespace = '[-a-zA-Z0-9._]{2,16}';
const chainIdReference = '[-a-zA-Z0-9._]{1,32}';
// See https://github.com/ChainAgnostic/CAIPs/issues/63
const assetReference = '[-a-zA-Z0-9._]{1,128}';
const accountAddress = '[a-zA-Z0-9._]{1,128}';
const accountAddress = '[-a-zA-Z0-9._]{1,128}';

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

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

import {debugFactory, stringify} from '@collabland/common';
import {URLSearchParams} from 'url';
import {

@@ -9,0 +10,0 @@ AccountId,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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