@audius/sdk 0.0.35 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NativeAudiusLibs.d.ts +7 -3
- package/dist/api/entityManager.d.ts +2 -1
- package/dist/index.cjs.js +38 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +38 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +38 -30
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +8387 -5048
- package/dist/native-libs.js.map +1 -1
- package/dist/services/solana/SolanaWeb3Manager.d.ts +2 -1
- package/dist/services/web3Manager/Web3Config.d.ts +1 -0
- package/package.json +4 -3
- package/src/NativeAudiusLibs.ts +69 -7
- package/src/api/entityManager.ts +11 -6
- package/src/services/solana/SolanaWeb3Manager.ts +6 -6
- package/src/services/web3Manager/Web3Config.ts +1 -0
- package/src/services/wormhole/Wormhole.ts +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -22,7 +22,8 @@ import { Transaction } from 'ethereumjs-tx';
|
|
|
22
22
|
import * as AudiusData from '@audius/anchor-audius-data';
|
|
23
23
|
import { idl } from '@audius/anchor-audius-data';
|
|
24
24
|
import anchor, { ProgramError, BN as BN$1 } from '@project-serum/anchor';
|
|
25
|
-
import
|
|
25
|
+
import * as solanaWeb3 from '@solana/web3.js';
|
|
26
|
+
import { PublicKey, SYSVAR_RENT_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, Secp256k1Program, TransactionInstruction, Keypair, Transaction as Transaction$1, Connection } from '@solana/web3.js';
|
|
26
27
|
import splToken, { ASSOCIATED_TOKEN_PROGRAM_ID, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
27
28
|
import borsh from 'borsh';
|
|
28
29
|
import BN from 'bn.js';
|
|
@@ -33409,9 +33410,9 @@ var formatProviders = function formatProviders(providers) {
|
|
|
33409
33410
|
};
|
|
33410
33411
|
|
|
33411
33412
|
var name = "@audius/sdk";
|
|
33412
|
-
var version = "0.0.
|
|
33413
|
+
var version = "0.0.36";
|
|
33413
33414
|
var audius = {
|
|
33414
|
-
releaseSHA: "
|
|
33415
|
+
releaseSHA: "6d1ca16dfb4944e5e5b83ee30e302fa4e6811da4"
|
|
33415
33416
|
};
|
|
33416
33417
|
var description = "";
|
|
33417
33418
|
var main = "dist/index.cjs.js";
|
|
@@ -33454,7 +33455,7 @@ var dependencies = {
|
|
|
33454
33455
|
"@improbable-eng/grpc-web-node-http-transport": "0.15.0",
|
|
33455
33456
|
"@project-serum/anchor": "0.24.1",
|
|
33456
33457
|
"@solana/spl-token": "0.1.8",
|
|
33457
|
-
"@solana/web3.js": "1.
|
|
33458
|
+
"@solana/web3.js": "1.53.0",
|
|
33458
33459
|
"abi-decoder": "2.4.0",
|
|
33459
33460
|
ajv: "6.12.2",
|
|
33460
33461
|
"async-retry": "1.3.1",
|
|
@@ -33507,6 +33508,7 @@ var devDependencies = {
|
|
|
33507
33508
|
"@types/expect": "24.3.0",
|
|
33508
33509
|
"@types/form-data": "^2.5.0",
|
|
33509
33510
|
"@types/hashids": "2.0.1",
|
|
33511
|
+
"@types/lodash": "4.14.149",
|
|
33510
33512
|
"@types/mocha": "9.1.0",
|
|
33511
33513
|
"@types/node-localstorage": "1.3.0",
|
|
33512
33514
|
"@types/pify": "^5.0.1",
|
|
@@ -35919,7 +35921,7 @@ var SolanaWeb3Manager = /*#__PURE__*/function () {
|
|
|
35919
35921
|
case 0:
|
|
35920
35922
|
_this$solanaWeb3Confi = this.solanaWeb3Config, solanaClusterEndpoint = _this$solanaWeb3Confi.solanaClusterEndpoint, mintAddress = _this$solanaWeb3Confi.mintAddress, solanaTokenAddress = _this$solanaWeb3Confi.solanaTokenAddress, claimableTokenPDA = _this$solanaWeb3Confi.claimableTokenPDA, feePayerAddress = _this$solanaWeb3Confi.feePayerAddress, claimableTokenProgramAddress = _this$solanaWeb3Confi.claimableTokenProgramAddress, rewardsManagerProgramId = _this$solanaWeb3Confi.rewardsManagerProgramId, rewardsManagerProgramPDA = _this$solanaWeb3Confi.rewardsManagerProgramPDA, rewardsManagerTokenPDA = _this$solanaWeb3Confi.rewardsManagerTokenPDA, useRelay = _this$solanaWeb3Confi.useRelay, feePayerKeypairs = _this$solanaWeb3Confi.feePayerKeypairs, confirmationTimeout = _this$solanaWeb3Confi.confirmationTimeout, audiusDataProgramId = _this$solanaWeb3Confi.audiusDataProgramId, audiusDataAdminStorageKeypairPublicKey = _this$solanaWeb3Confi.audiusDataAdminStorageKeypairPublicKey, audiusDataIdl = _this$solanaWeb3Confi.audiusDataIdl;
|
|
35921
35923
|
this.solanaClusterEndpoint = solanaClusterEndpoint;
|
|
35922
|
-
this.connection = new
|
|
35924
|
+
this.connection = new Connection(this.solanaClusterEndpoint, {
|
|
35923
35925
|
confirmTransactionInitialTimeout: confirmationTimeout || DEFAULT_CONNECTION_CONFIRMATION_TIMEOUT_MS
|
|
35924
35926
|
});
|
|
35925
35927
|
this.transactionHandler = new TransactionHandler({
|
|
@@ -35979,9 +35981,8 @@ var SolanaWeb3Manager = /*#__PURE__*/function () {
|
|
|
35979
35981
|
this.audiusDataIdl = audiusDataIdl || idl;
|
|
35980
35982
|
|
|
35981
35983
|
if (this.audiusDataProgramId && this.audiusDataAdminStorageKeypairPublicKey && this.audiusDataIdl) {
|
|
35982
|
-
connection = new
|
|
35983
|
-
anchorProvider = new anchor.AnchorProvider(connection,
|
|
35984
|
-
solanaWeb3.Keypair.generate(), anchor.AnchorProvider.defaultOptions());
|
|
35984
|
+
connection = new Connection(this.solanaClusterEndpoint, anchor.AnchorProvider.defaultOptions());
|
|
35985
|
+
anchorProvider = new anchor.AnchorProvider(connection, Keypair.generate(), anchor.AnchorProvider.defaultOptions());
|
|
35985
35986
|
this.anchorProgram = new anchor.Program(this.audiusDataIdl, audiusDataProgramId, anchorProvider);
|
|
35986
35987
|
}
|
|
35987
35988
|
|
|
@@ -50228,7 +50229,7 @@ var Wormhole = /*#__PURE__*/function () {
|
|
|
50228
50229
|
wAudioAmount = wAudioFromWeiAudio(amount); // Generate a solana keypair derived from the hedgehog private key
|
|
50229
50230
|
// NOTE: The into to fromSeed is a 32 bytes Uint8Array
|
|
50230
50231
|
|
|
50231
|
-
rootSolanaAccount =
|
|
50232
|
+
rootSolanaAccount = Keypair.fromSeed((_this$hedgehog$wallet = this.hedgehog.wallet) === null || _this$hedgehog$wallet === void 0 ? void 0 : _this$hedgehog$wallet.getPrivateKey());
|
|
50232
50233
|
solanaAddress = rootSolanaAccount.publicKey.toString();
|
|
50233
50234
|
logs.push("Root Solana Account: ".concat(solanaAddress)); // Find the token account owned by the root solana account and get the token account's info
|
|
50234
50235
|
|
|
@@ -57177,13 +57178,13 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57177
57178
|
key: "createPlaylist",
|
|
57178
57179
|
value: function () {
|
|
57179
57180
|
var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
|
|
57180
|
-
var playlistId, playlistName, trackIds, description, isAlbum, isPrivate, coverArt, responseValues, currentUserId, userId, createAction, entityType, updatedPlaylistImage, web3, currentBlockNumber, currentBlock, tracks,
|
|
57181
|
+
var playlistId, playlistName, trackIds, description, isAlbum, isPrivate, coverArt, coverArtSizes, responseValues, _dirCID, currentUserId, userId, createAction, entityType, dirCID, updatedPlaylistImage, web3, currentBlockNumber, currentBlock, tracks, metadata, _yield$this$creatorNo, metadataMultihash, manageEntityResponse, txReceipt, error;
|
|
57181
57182
|
|
|
57182
57183
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
57183
57184
|
while (1) {
|
|
57184
57185
|
switch (_context2.prev = _context2.next) {
|
|
57185
57186
|
case 0:
|
|
57186
|
-
playlistId = _ref.playlistId, playlistName = _ref.playlistName, trackIds = _ref.trackIds, description = _ref.description, isAlbum = _ref.isAlbum, isPrivate = _ref.isPrivate, coverArt = _ref.coverArt;
|
|
57187
|
+
playlistId = _ref.playlistId, playlistName = _ref.playlistName, trackIds = _ref.trackIds, description = _ref.description, isAlbum = _ref.isAlbum, isPrivate = _ref.isPrivate, coverArt = _ref.coverArt, coverArtSizes = _ref.coverArtSizes;
|
|
57187
57188
|
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57188
57189
|
_context2.prev = 2;
|
|
57189
57190
|
currentUserId = this.userStateManager.getCurrentUserId();
|
|
@@ -57201,22 +57202,31 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57201
57202
|
createAction = Action.CREATE;
|
|
57202
57203
|
entityType = EntityType.PLAYLIST;
|
|
57203
57204
|
this.REQUIRES(Services.CREATOR_NODE);
|
|
57204
|
-
|
|
57205
|
+
|
|
57206
|
+
if (!coverArt) {
|
|
57207
|
+
_context2.next = 16;
|
|
57208
|
+
break;
|
|
57209
|
+
}
|
|
57210
|
+
|
|
57211
|
+
_context2.next = 14;
|
|
57205
57212
|
return this.creatorNode.uploadImage(coverArt, true // square
|
|
57206
57213
|
);
|
|
57207
57214
|
|
|
57208
|
-
case
|
|
57215
|
+
case 14:
|
|
57209
57216
|
updatedPlaylistImage = _context2.sent;
|
|
57217
|
+
dirCID = updatedPlaylistImage.dirCID;
|
|
57218
|
+
|
|
57219
|
+
case 16:
|
|
57210
57220
|
web3 = this.web3Manager.getWeb3();
|
|
57211
|
-
_context2.next =
|
|
57221
|
+
_context2.next = 19;
|
|
57212
57222
|
return web3.eth.getBlockNumber();
|
|
57213
57223
|
|
|
57214
|
-
case
|
|
57224
|
+
case 19:
|
|
57215
57225
|
currentBlockNumber = _context2.sent;
|
|
57216
|
-
_context2.next =
|
|
57226
|
+
_context2.next = 22;
|
|
57217
57227
|
return web3.eth.getBlock(currentBlockNumber);
|
|
57218
57228
|
|
|
57219
|
-
case
|
|
57229
|
+
case 22:
|
|
57220
57230
|
currentBlock = _context2.sent;
|
|
57221
57231
|
tracks = trackIds.map(function (trackId) {
|
|
57222
57232
|
return {
|
|
@@ -57224,25 +57234,24 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57224
57234
|
time: currentBlock.timestamp
|
|
57225
57235
|
};
|
|
57226
57236
|
});
|
|
57227
|
-
dirCID = updatedPlaylistImage.dirCID;
|
|
57228
57237
|
metadata = {
|
|
57229
57238
|
playlist_id: playlistId,
|
|
57230
57239
|
playlist_contents: {
|
|
57231
57240
|
track_ids: tracks
|
|
57232
57241
|
},
|
|
57233
57242
|
playlist_name: playlistName,
|
|
57234
|
-
playlist_image_sizes_multihash: dirCID,
|
|
57243
|
+
playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID : coverArtSizes,
|
|
57235
57244
|
description: description,
|
|
57236
57245
|
is_album: isAlbum,
|
|
57237
57246
|
is_private: isPrivate
|
|
57238
57247
|
};
|
|
57239
|
-
_context2.next =
|
|
57248
|
+
_context2.next = 27;
|
|
57240
57249
|
return this.creatorNode.uploadPlaylistMetadata(metadata);
|
|
57241
57250
|
|
|
57242
|
-
case
|
|
57251
|
+
case 27:
|
|
57243
57252
|
_yield$this$creatorNo = _context2.sent;
|
|
57244
57253
|
metadataMultihash = _yield$this$creatorNo.metadataMultihash;
|
|
57245
|
-
_context2.next =
|
|
57254
|
+
_context2.next = 31;
|
|
57246
57255
|
return this.manageEntity({
|
|
57247
57256
|
userId: userId,
|
|
57248
57257
|
entityType: entityType,
|
|
@@ -57251,7 +57260,7 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57251
57260
|
metadataMultihash: metadataMultihash
|
|
57252
57261
|
});
|
|
57253
57262
|
|
|
57254
|
-
case
|
|
57263
|
+
case 31:
|
|
57255
57264
|
manageEntityResponse = _context2.sent;
|
|
57256
57265
|
txReceipt = manageEntityResponse.txReceipt;
|
|
57257
57266
|
responseValues.blockHash = txReceipt.blockHash;
|
|
@@ -57259,19 +57268,19 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57259
57268
|
responseValues.playlistId = playlistId;
|
|
57260
57269
|
return _context2.abrupt("return", responseValues);
|
|
57261
57270
|
|
|
57262
|
-
case
|
|
57263
|
-
_context2.prev =
|
|
57271
|
+
case 39:
|
|
57272
|
+
_context2.prev = 39;
|
|
57264
57273
|
_context2.t0 = _context2["catch"](2);
|
|
57265
57274
|
error = _context2.t0.message;
|
|
57266
57275
|
responseValues.error = error;
|
|
57267
57276
|
return _context2.abrupt("return", responseValues);
|
|
57268
57277
|
|
|
57269
|
-
case
|
|
57278
|
+
case 44:
|
|
57270
57279
|
case "end":
|
|
57271
57280
|
return _context2.stop();
|
|
57272
57281
|
}
|
|
57273
57282
|
}
|
|
57274
|
-
}, _callee2, this, [[2,
|
|
57283
|
+
}, _callee2, this, [[2, 39]]);
|
|
57275
57284
|
}));
|
|
57276
57285
|
|
|
57277
57286
|
function createPlaylist(_x3) {
|
|
@@ -57355,7 +57364,7 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57355
57364
|
key: "editPlaylist",
|
|
57356
57365
|
value: function () {
|
|
57357
57366
|
var _editPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref3) {
|
|
57358
|
-
var playlistId, playlistName, description, isAlbum, isPrivate, coverArt, responseValues,
|
|
57367
|
+
var playlistId, playlistName, description, isAlbum, isPrivate, coverArt, responseValues, _dirCID2, currentUserId, userId, updateAction, entityType, dirCID, updatedPlaylistImage, playlist, existingPlaylistTracks, metadata, _yield$this$creatorNo2, metadataMultihash, resp, txReceipt, error;
|
|
57359
57368
|
|
|
57360
57369
|
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
57361
57370
|
while (1) {
|
|
@@ -57415,7 +57424,7 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57415
57424
|
track_ids: existingPlaylistTracks
|
|
57416
57425
|
},
|
|
57417
57426
|
playlist_name: playlistName !== null && playlistName !== void 0 ? playlistName : playlist.playlist_name,
|
|
57418
|
-
playlist_image_sizes_multihash: (
|
|
57427
|
+
playlist_image_sizes_multihash: (_dirCID2 = dirCID) !== null && _dirCID2 !== void 0 ? _dirCID2 : playlist.cover_art,
|
|
57419
57428
|
description: description !== null && description !== void 0 ? description : playlist.description,
|
|
57420
57429
|
is_album: isAlbum !== null && isAlbum !== void 0 ? isAlbum : playlist.is_album,
|
|
57421
57430
|
is_private: isPrivate !== null && isPrivate !== void 0 ? isPrivate : playlist.is_private
|