Skip to content

Commit

Permalink
Merge pull request #2822 from build-5/dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
adamunchained authored Feb 21, 2024
2 parents c0db2dc + c3f8072 commit e1bb19d
Show file tree
Hide file tree
Showing 38 changed files with 2,158 additions and 1,972 deletions.
3,819 changes: 2,018 additions & 1,801 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"dependencies": {
"@build-5/interfaces": "*",
"dayjs": "1.11.10",
"firebase-admin": "11.11.0",
"firebase-admin": "12.0.0",
"jsonwebtoken": "9.0.2",
"lodash": "4.17.21"
},
"devDependencies": {
"@types/lodash": "4.14.201",
"dotenv": "16.3.1",
"@types/lodash": "4.14.202",
"dotenv": "16.4.5",
"glob": "8.0.3",
"typescript": "5.2.2"
"typescript": "5.3.3"
}
}
3 changes: 2 additions & 1 deletion packages/database/src/storage/storage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Bucket } from '@build-5/interfaces';
import { Bucket as FBucket } from '@google-cloud/storage';
import { Storage } from 'firebase-admin/storage';
import { get } from 'lodash';
import { FirebaseApp } from '../app/app';
import { IBucket, IStorage } from './interfaces';

Expand Down Expand Up @@ -28,7 +29,7 @@ export class FirebaseBucket implements IBucket {

public upload = async (path: string, destination: string, metadata: Record<string, unknown>) => {
const response = await this.bucket.upload(path, { destination, metadata });
return response[1].mediaLink;
return get(response[1], 'mediaLink', '');
};

public download = async (fileName: string, destination: string) => {
Expand Down
68 changes: 34 additions & 34 deletions packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,41 @@
},
"devDependencies": {
"@types/busboy": "1.5.3",
"@types/chai": "4.3.10",
"@types/chai": "4.3.11",
"@types/chance": "1.1.6",
"@types/child-process-promise": "2.2.5",
"@types/cors": "2.8.16",
"@types/crypto-js": "4.2.1",
"@types/child-process-promise": "2.2.6",
"@types/cors": "2.8.17",
"@types/crypto-js": "4.2.2",
"@types/download": "8.0.5",
"@types/jest": "29.5.8",
"@types/jest": "29.5.12",
"@types/jsonwebtoken": "9.0.5",
"@types/lodash": "4.14.201",
"@types/lodash": "4.14.202",
"@types/mime-types": "2.1.4",
"@types/sharp": "0.32.0",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"@typescript-eslint/eslint-plugin": "7.0.2",
"@typescript-eslint/parser": "7.0.2",
"babel-jest": "29.7.0",
"chance": "1.1.11",
"dotenv": "16.3.1",
"eslint": "8.53.0",
"dotenv": "16.4.5",
"eslint": "8.56.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "9.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-angular": "4.1.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jsdoc": "46.9.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "48.1.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-prettier": "5.0.1",
"firebase-functions-test": "3.1.0",
"eslint-plugin-prettier": "5.1.3",
"firebase-functions-test": "3.1.1",
"glob": "8.0.3",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"prettier": "3.1.0",
"prettier-eslint": "16.1.2",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"prettier": "3.2.5",
"prettier-eslint": "16.3.0",
"ts-jest": "29.1.2",
"ts-node": "10.9.2",
"ts-sinon": "2.0.2",
"typescript": "5.2.2"
"typescript": "5.3.3"
},
"dependencies": {
"@build-5/database": "*",
Expand All @@ -74,35 +75,34 @@
"@iota/crypto.js-next": "npm:@iota/[email protected]",
"@iota/iota.js": "1.8.6",
"@iota/iota.js-next": "npm:@iota/[email protected]",
"@iota/sdk": "1.1.4",
"@iota/sdk": "1.1.5",
"@iota/util.js": "1.8.6",
"@iota/util.js-next": "npm:@iota/[email protected]",
"@metamask/eth-sig-util": "7.0.0",
"algoliasearch": "4.20.0",
"axios": "1.6.1",
"@metamask/eth-sig-util": "7.0.1",
"algoliasearch": "4.22.1",
"axios": "1.6.7",
"bip39": "3.1.0",
"busboy": "1.6.0",
"child-process-promise": "2.2.1",
"cloudevents": "8.0.0",
"cors": "2.8.5",
"crypto-js": "4.2.0",
"dayjs": "1.11.10",
"ethers": "6.8.1",
"ethers": "6.11.1",
"files-from-path": "^1.0.4",
"firebase-admin": "11.11.0",
"firebase-functions": "4.5.0",
"glob": "8.0.3",
"firebase-admin": "12.0.0",
"firebase-functions": "4.7.0",
"interfaces": "0.0.3",
"is-ipfs": "8.0.1",
"joi": "17.12.0",
"js-big-decimal": "2.0.4",
"is-ipfs": "8.0.4",
"joi": "17.12.1",
"js-big-decimal": "2.0.7",
"jsonwebtoken": "9.0.2",
"lodash": "4.17.21",
"mime-types": "2.1.35",
"nft.storage": "7.1.1",
"node-ipinfo": "3.5.0",
"protobufjs": "7.2.5",
"node-ipinfo": "3.5.1",
"protobufjs": "7.2.6",
"rxjs": "7.8.1",
"sharp": "0.32.6"
"sharp": "0.33.2"
}
}
15 changes: 6 additions & 9 deletions packages/functions/src/services/wallet/IotaWalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
BasicOutput,
BasicOutputBuilderParams,
CoinType,
CommonOutput,
FoundryOutput,
INativeToken,
NftOutput,
NftOutputBuilderParams,
OutputType,
Expand All @@ -22,7 +22,7 @@ import {
Unlock,
Utils,
} from '@iota/sdk';
import { cloneDeep, head, isEmpty } from 'lodash';
import { cloneDeep, get, head, isEmpty } from 'lodash';
import { mergeOutputs, packBasicOutput } from '../../utils/basic-output.utils';
import { Bech32AddressHelper } from '../../utils/bech32-address.helper';
import { createUnlock, packEssence, submitBlock } from '../../utils/block.utils';
Expand All @@ -46,13 +46,10 @@ export class IotaWallet extends Wallet {
let totalAmount = BigInt(0);
const totalNativeTokens: { [id: string]: number } = {};
for (const outputResponse of outputs) {
const output = outputResponse.output;
if (output instanceof CommonOutput) {
(output as CommonOutput).getNativeTokens()?.forEach((token) => {
totalNativeTokens[token.id] = (totalNativeTokens[token.id] || 0) + Number(token.amount);
});
}
totalAmount += output.getAmount();
get(outputResponse.output, 'nativeTokens', [] as INativeToken[]).forEach((token) => {
totalNativeTokens[token.id] = (totalNativeTokens[token.id] || 0) + Number(token.amount);
});
totalAmount += outputResponse.output.getAmount();
}
return { amount: Number(totalAmount), nativeTokens: totalNativeTokens };
};
Expand Down
4 changes: 1 addition & 3 deletions packages/functions/src/triggers/token.trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ const setIpfsData = async (token: Token) => {
const onTokenVaultEmptied = async (token: Token) => {
const wallet = await WalletService.newWallet(token.mintingData?.network);
const { amount: vaultBalance } = await wallet.getBalance(token.mintingData?.vaultAddress!);
const minter = await build5Db()
.doc(`${COL.MEMBER}/${token.mintingData?.mintedBy}`)
.get<Member>();
const minter = await build5Db().doc(`${COL.MEMBER}/${token.mintingData?.mintedBy}`).get<Member>();
const paymentsSnap = await build5Db()
.collection(COL.TRANSACTION)
.where('type', '==', TransactionType.PAYMENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,8 @@ const onNftMinted = async (transaction: Transaction) => {
get(order, 'payload.nftOutputAmount', 0);

const member = await build5Db().doc(`${COL.MEMBER}/${transaction.member}`).get<Member>();
const collection = await build5Db()
.doc(`${COL.COLLECTION}/${nft?.collection}`)
.get<Collection>();
const space = await build5Db()
.doc(`${COL.SPACE}/${collection?.space}`)
.get<Space>();
const collection = await build5Db().doc(`${COL.COLLECTION}/${nft?.collection}`).get<Collection>();
const space = await build5Db().doc(`${COL.SPACE}/${collection?.space}`).get<Space>();

const remainder = order.payload.amount! - storageDepositTotal;

Expand Down Expand Up @@ -232,12 +228,8 @@ const onNftUpdated = async (transaction: Transaction) => {
const { amount: balance } = await wallet.getBalance(order.payload.targetAddress!);

const member = await build5Db().doc(`${COL.MEMBER}/${transaction.member}`).get<Member>();
const collection = await build5Db()
.doc(`${COL.COLLECTION}/${nft?.collection}`)
.get<Collection>();
const space = await build5Db()
.doc(`${COL.SPACE}/${collection?.space}`)
.get<Space>();
const collection = await build5Db().doc(`${COL.COLLECTION}/${nft?.collection}`).get<Collection>();
const space = await build5Db().doc(`${COL.SPACE}/${collection?.space}`).get<Space>();

if (Number(balance)) {
const creditTransaction: Transaction = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ const onFoundryMinted = async (transaction: Transaction) => {
});

const token = <Token>await build5Db().doc(`${COL.TOKEN}/${transaction.payload.token}`).get();
const member = <Member>await build5Db()
.doc(`${COL.MEMBER}/${token.mintingData?.mintedBy}`)
.get();
const member = <Member>await build5Db().doc(`${COL.MEMBER}/${token.mintingData?.mintedBy}`).get();
const order: Transaction = {
project: getProject(transaction),
type: TransactionType.MINT_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ describe('Base token trading', () => {
customMetadata: { request: { requestType: TangleRequestType.SELL_TOKEN } },
});

const query = build5Db()
.collection(COL.TOKEN_MARKET)
.where('owner', '==', h.seller?.uid);
const query = build5Db().collection(COL.TOKEN_MARKET).where('owner', '==', h.seller?.uid);
await wait(async () => {
const snap = await query.get();
return snap.length === 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ describe('Base token trading', () => {
},
});

const query = build5Db()
.collection(COL.TOKEN_MARKET)
.where('owner', '==', h.buyer?.uid);
const query = build5Db().collection(COL.TOKEN_MARKET).where('owner', '==', h.buyer?.uid);
await wait(async () => {
const snap = await query.get();
return snap.length === 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ describe('Collection minting', () => {
expect(collectionData.total).toBe(
unsoldMintingOptions === UnsoldMintingOptions.BURN_UNSOLD ? 1 : 2,
);
nft = <Nft | undefined>await build5Db()
.doc(`${COL.NFT}/${nft?.uid}`)
.get();
nft = <Nft | undefined>await build5Db().doc(`${COL.NFT}/${nft?.uid}`).get();
expect(nft === undefined).toBe(unsoldMintingOptions === UnsoldMintingOptions.BURN_UNSOLD);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ describe('Collection minting', () => {
await build5Db().doc(`${COL.COLLECTION}/${helper.collection}`).get()
);
expect(collectionData.total).toBe(1);
nft = <Nft>await build5Db()
.doc(`${COL.NFT}/${nft?.uid}`)
.get();
nft = <Nft>await build5Db().doc(`${COL.NFT}/${nft?.uid}`).get();
expect(nft.availablePrice).toBe(2 * MIN_IOTA_AMOUNT);
expect(nft.price).toBe(2 * MIN_IOTA_AMOUNT);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ describe('Collection minting', () => {
await build5Db().doc(`${COL.COLLECTION}/${helper.collection}`).get()
);
expect(collectionData.total).toBe(1);
nft = <Nft>await build5Db()
.doc(`${COL.NFT}/${nft?.uid}`)
.get();
nft = <Nft>await build5Db().doc(`${COL.NFT}/${nft?.uid}`).get();
expect(nft.isOwned).toBe(true);
expect(nft.owner).toBe(helper.guardian);
expect(nft.sold).toBe(true);
Expand Down
4 changes: 1 addition & 3 deletions packages/functions/test-tangle/nft-bulk/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export class Helper {
const cCollection = await testEnv.wrap(createCollection)({});
expect(cCollection?.uid).toBeDefined();

await build5Db()
.doc(`${COL.COLLECTION}/${cCollection?.uid}`)
.update({ approved: true });
await build5Db().doc(`${COL.COLLECTION}/${cCollection?.uid}`).update({ approved: true });
const collection = <Collection>cCollection;

const nft = await this.createNft(address, collection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ describe('Stake nft', () => {
return snap.length === 1;
});

const nftQuery = build5Db()
.collection(COL.NFT)
.where('space', '==', helper.space?.uid);
const nftQuery = build5Db().collection(COL.NFT).where('space', '==', helper.space?.uid);
const nftSnap = await nftQuery.get<Nft>();
expect(nftSnap.length).toBe(1);
expect(nftSnap[0]?.space).toBe(award.space);
Expand Down
16 changes: 10 additions & 6 deletions packages/functions/test-tangle/staking/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ export class Helper {
expect(stake.token).toBe(this.token?.uid!);

await wait(async () => {
const currTokenStats = <TokenStats | undefined>await build5Db()
.doc(`${COL.TOKEN}/${this.token?.uid}/${SUB_COL.STATS}/${this.token?.uid}`)
.get();
const currTokenStats = <TokenStats | undefined>(
await build5Db()
.doc(`${COL.TOKEN}/${this.token?.uid}/${SUB_COL.STATS}/${this.token?.uid}`)
.get()
);
return (
(currTokenStats?.stakes || {})[type || StakeType.DYNAMIC]?.totalAmount !==
(this.tokenStats?.stakes || {})[type || StakeType.DYNAMIC]?.totalAmount
Expand Down Expand Up @@ -180,9 +182,11 @@ export class Helper {
type: StakeType,
membersCount: number,
) => {
this.tokenStats = <TokenStats>await build5Db()
.doc(`${COL.TOKEN}/${this.token!.uid}/${SUB_COL.STATS}/${this.token?.uid}`)
.get();
this.tokenStats = <TokenStats>(
await build5Db()
.doc(`${COL.TOKEN}/${this.token!.uid}/${SUB_COL.STATS}/${this.token?.uid}`)
.get()
);
expect(this.tokenStats.stakes![type].amount).toBe(stakeAmount);
expect(this.tokenStats.stakes![type].totalAmount).toBe(stakeTotalAmount);
expect(this.tokenStats.stakes![type].value).toBe(stakeValue);
Expand Down
4 changes: 1 addition & 3 deletions packages/functions/test-tangle/staking/staking_3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ describe('Staking test', () => {

const validateMemberTradingFee = async (expected: number) => {
await wait(async () => {
helper.member = <Member>await build5Db()
.doc(`${COL.MEMBER}/${helper.member?.uid}`)
.get();
helper.member = <Member>await build5Db().doc(`${COL.MEMBER}/${helper.member?.uid}`).get();
return helper.member.tokenTradingFeePercentage === expected;
});
};
Expand Down
8 changes: 2 additions & 6 deletions packages/functions/test-tangle/staking/staking_4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ describe('Stake reward test test', () => {

await awaitTransactionConfirmationsForToken(helper.token?.uid!);

const member = <Member>await build5Db()
.doc(`${COL.MEMBER}/${helper.member?.uid}`)
.get();
const member = <Member>await build5Db().doc(`${COL.MEMBER}/${helper.member?.uid}`).get();
for (const address of [helper.memberAddress?.bech32!, getAddress(member, Network.RMS)]) {
const outputs = await helper.walletService!.getOutputs(address, [], false, true);
const nativeTokens = Object.values(outputs).reduce(
Expand Down Expand Up @@ -279,9 +277,7 @@ describe('Stake reward test test', () => {

await awaitTransactionConfirmationsForToken(helper.token?.uid!);

const member = <Member>await build5Db()
.doc(`${COL.MEMBER}/${helper.member?.uid}`)
.get();
const member = <Member>await build5Db().doc(`${COL.MEMBER}/${helper.member?.uid}`).get();
for (const address of [helper.memberAddress?.bech32!, getAddress(member, Network.RMS)]) {
const outputs = await helper.walletService!.getOutputs(address, [], false, true);
const nativeTokens = Object.values(outputs).reduce(
Expand Down
10 changes: 5 additions & 5 deletions packages/functions/test-tangle/workflow-online.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import fs from 'fs';
import glob from 'glob';

describe('Workflow test', () => {
it('Test if workflow contains all files', async () => {
Expand All @@ -8,12 +7,13 @@ describe('Workflow test', () => {
);
const workflowTxt = buffer.toString();

const glob = require('glob');
const testFileNames = glob
.sync(`./test-tangle/**/*.spec.ts`)
.filter((f) => !f.includes('exclude'))
.filter((f) => !f.includes('only.spec.ts'))
.filter((f) => !f.includes('web3.spec'))
.filter((f) => !f.includes('dbRoll'));
.filter((f: any) => !f.includes('exclude'))
.filter((f: any) => !f.includes('only.spec.ts'))
.filter((f: any) => !f.includes('web3.spec'))
.filter((f: any) => !f.includes('dbRoll'));
for (const testFileName of testFileNames) {
if (!workflowTxt.includes(testFileName)) {
throw Error(
Expand Down
Loading

0 comments on commit e1bb19d

Please sign in to comment.